summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/mgag200/mgag200_mode.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2022-06-01 13:25:20 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2022-06-07 09:40:04 +0200
commit98da4b99a0525c222dab7cd8e73153eaea062dc3 (patch)
tree704282cb63f0d9d544f6507ad6111286d1242427 /drivers/gpu/drm/mgag200/mgag200_mode.c
parent21e74bf99596d91411b6b51340c05ff92a7a4a01 (diff)
downloadlwn-98da4b99a0525c222dab7cd8e73153eaea062dc3.tar.gz
lwn-98da4b99a0525c222dab7cd8e73153eaea062dc3.zip
drm/mgag200: Store maximum resolution and memory bandwidth in device info
The maximum resolution and memory bandwidth are model-specific limits. Both are used during display-mode validation. Store the values in struct mgag200_device_info and simplify the validation code. v2: * 'bandwith' -> 'bandwidth' in commit message Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Tested-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220601112522.5774-9-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/mgag200/mgag200_mode.c')
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_mode.c69
1 files changed, 20 insertions, 49 deletions
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index f5e1a89e0bfe..aa85558faa1b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -725,30 +725,17 @@ static enum drm_mode_status
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) {
@@ -1028,7 +1015,7 @@ static enum drm_mode_status mgag200_mode_config_mode_valid(struct drm_device *de
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;
@@ -1038,30 +1025,14 @@ static enum drm_mode_status mgag200_mode_config_mode_valid(struct drm_device *de
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;
}