#define IS_G200_SE(mdev) (mdev->type == G200_SE_A || mdev->type == G200_SE_B)
struct mgag200_device_info {
+ u16 max_hdisplay;
+ u16 max_vdisplay;
+
+ /*
+ * Maximum memory bandwidth (MiB/sec). Setting this to zero disables
+ * the rsp test during mode validation.
+ */
+ unsigned long max_mem_bandwidth;
+
/*
* HW does not handle 'startadd' register correctly. Always set
* it's value to 0.
bool bug_no_startadd:1;
};
-#define MGAG200_DEVICE_INFO_INIT(_bug_no_startadd) \
+#define MGAG200_DEVICE_INFO_INIT(_max_hdisplay, _max_vdisplay, _max_mem_bandwidth, \
+ _bug_no_startadd) \
{ \
+ .max_hdisplay = (_max_hdisplay), \
+ .max_vdisplay = (_max_vdisplay), \
+ .max_mem_bandwidth = (_max_mem_bandwidth), \
.bug_no_startadd = (_bug_no_startadd), \
}
*/
static const struct mgag200_device_info mgag200_g200_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false);
static void mgag200_g200_interpret_bios(struct mgag200_g200_device *g200,
const unsigned char *bios, size_t size)
*/
static const struct mgag200_device_info mgag200_g200eh_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 37500, false);
struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type)
*/
static const struct mgag200_device_info mgag200_g200eh3_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false);
struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
const struct drm_driver *drv,
*/
static const struct mgag200_device_info mgag200_g200er_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false);
struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type)
*/
static const struct mgag200_device_info mgag200_g200ev_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 32700, false);
struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type)
*/
static const struct mgag200_device_info mgag200_g200ew3_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false);
static resource_size_t mgag200_g200ew3_device_probe_vram(struct mga_device *mdev)
{
* DRM device
*/
-static const struct mgag200_device_info mgag200_g200se_a_device_info =
- MGAG200_DEVICE_INFO_INIT(true);
+static const struct mgag200_device_info mgag200_g200se_a_01_device_info =
+ MGAG200_DEVICE_INFO_INIT(1600, 1200, 24400, true);
-static const struct mgag200_device_info mgag200_g200se_b_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+static const struct mgag200_device_info mgag200_g200se_a_02_device_info =
+ MGAG200_DEVICE_INFO_INIT(1920, 1200, 30100, true);
-static void mgag200_g200se_init_unique_id(struct mgag200_g200se_device *g200se)
+static const struct mgag200_device_info mgag200_g200se_a_03_device_info =
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false);
+
+static const struct mgag200_device_info mgag200_g200se_b_01_device_info =
+ MGAG200_DEVICE_INFO_INIT(1600, 1200, 24400, false);
+
+static const struct mgag200_device_info mgag200_g200se_b_02_device_info =
+ MGAG200_DEVICE_INFO_INIT(1920, 1200, 30100, false);
+
+static const struct mgag200_device_info mgag200_g200se_b_03_device_info =
+ MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false);
+
+static int mgag200_g200se_init_unique_rev_id(struct mgag200_g200se_device *g200se)
{
struct mga_device *mdev = &g200se->base;
struct drm_device *dev = &mdev->base;
/* stash G200 SE model number for later use */
g200se->unique_rev_id = RREG32(0x1e24);
+ if (!g200se->unique_rev_id)
+ return -ENODEV;
drm_dbg(dev, "G200 SE unique revision id is 0x%x\n", g200se->unique_rev_id);
+
+ return 0;
}
struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
if (ret)
return ERR_PTR(ret);
- mgag200_g200se_init_unique_id(g200se);
+ ret = mgag200_g200se_init_unique_rev_id(g200se);
+ if (ret)
+ return ERR_PTR(ret);
switch (type) {
case G200_SE_A:
- info = &mgag200_g200se_a_device_info;
+ if (g200se->unique_rev_id >= 0x03)
+ info = &mgag200_g200se_a_03_device_info;
+ else if (g200se->unique_rev_id >= 0x02)
+ info = &mgag200_g200se_a_02_device_info;
+ else
+ info = &mgag200_g200se_a_01_device_info;
break;
case G200_SE_B:
- info = &mgag200_g200se_b_device_info;
+ if (g200se->unique_rev_id >= 0x03)
+ info = &mgag200_g200se_b_03_device_info;
+ else if (g200se->unique_rev_id >= 0x02)
+ info = &mgag200_g200se_b_02_device_info;
+ else
+ info = &mgag200_g200se_b_01_device_info;
break;
default:
return ERR_PTR(-EINVAL);
*/
static const struct mgag200_device_info mgag200_g200wb_device_info =
- MGAG200_DEVICE_INFO_INIT(false);
+ MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, false);
struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
enum mga_type type)
mgag200_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
const struct drm_display_mode *mode)
{
- struct drm_device *dev = pipe->crtc.dev;
- struct mga_device *mdev = to_mga_device(dev);
- struct mgag200_g200se_device *g200se;
-
- if (IS_G200_SE(mdev)) {
- g200se = to_mgag200_g200se_device(dev);
-
- if (g200se->unique_rev_id == 0x01) {
- if (mode->hdisplay > 1600)
- return MODE_VIRTUAL_X;
- if (mode->vdisplay > 1200)
- return MODE_VIRTUAL_Y;
- } else if (g200se->unique_rev_id == 0x02) {
- if (mode->hdisplay > 1920)
- return MODE_VIRTUAL_X;
- if (mode->vdisplay > 1200)
- return MODE_VIRTUAL_Y;
- }
- } else if (mdev->type == G200_WB) {
- if (mode->hdisplay > 1280)
- return MODE_VIRTUAL_X;
- if (mode->vdisplay > 1024)
- return MODE_VIRTUAL_Y;
- }
+ struct mga_device *mdev = to_mga_device(pipe->crtc.dev);
+ const struct mgag200_device_info *info = mdev->info;
+
+ /*
+ * Some devices have additional limits on the size of the
+ * display mode.
+ */
+ if (mode->hdisplay > info->max_hdisplay)
+ return MODE_VIRTUAL_X;
+ if (mode->vdisplay > info->max_vdisplay)
+ return MODE_VIRTUAL_Y;
if ((mode->hdisplay % 8) != 0 || (mode->hsync_start % 8) != 0 ||
(mode->hsync_end % 8) != 0 || (mode->htotal % 8) != 0) {
static const unsigned int max_bpp = 4; // DRM_FORMAT_XRGB8888
struct mga_device *mdev = to_mga_device(dev);
unsigned long fbsize, fbpages, max_fbpages;
- struct mgag200_g200se_device *g200se;
+ const struct mgag200_device_info *info = mdev->info;
max_fbpages = mdev->vram_available >> PAGE_SHIFT;
if (fbpages > max_fbpages)
return MODE_MEM;
- if (IS_G200_SE(mdev)) {
- g200se = to_mgag200_g200se_device(dev);
-
- if (g200se->unique_rev_id == 0x01) {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (24400 * 1024))
- return MODE_BAD;
- } else if (g200se->unique_rev_id == 0x02) {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (30100 * 1024))
- return MODE_BAD;
- } else {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (55000 * 1024))
- return MODE_BAD;
- }
- } else if (mdev->type == G200_WB) {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (31877 * 1024))
- return MODE_BAD;
- } else if (mdev->type == G200_EV) {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (32700 * 1024))
- return MODE_BAD;
- } else if (mdev->type == G200_EH) {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (37500 * 1024))
- return MODE_BAD;
- } else if (mdev->type == G200_ER) {
- if (mgag200_calculate_mode_bandwidth(mode, max_bpp * 8) > (55000 * 1024))
+ /*
+ * Test the mode's required memory bandwidth if the device
+ * specifies a maximum. Not all devices do though.
+ */
+ if (info->max_mem_bandwidth) {
+ uint32_t mode_bandwidth = mgag200_calculate_mode_bandwidth(mode, max_bpp * 8);
+
+ if (mode_bandwidth > (info->max_mem_bandwidth * 1024))
return MODE_BAD;
}