drm/mgag200: Store vidrst flag in device info
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 1 Jun 2022 11:25:21 +0000 (13:25 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Tue, 7 Jun 2022 07:40:08 +0000 (09:40 +0200)
Set new vidrst flag in device info for models that synchronize with
external sources (i.e., BMCs). In modesetting, set the corresponding
bits from the device-info flag.

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-10-tzimmermann@suse.de
drivers/gpu/drm/mgag200/mgag200_drv.h
drivers/gpu/drm/mgag200/mgag200_g200.c
drivers/gpu/drm/mgag200/mgag200_g200eh.c
drivers/gpu/drm/mgag200/mgag200_g200eh3.c
drivers/gpu/drm/mgag200/mgag200_g200er.c
drivers/gpu/drm/mgag200/mgag200_g200ev.c
drivers/gpu/drm/mgag200/mgag200_g200ew3.c
drivers/gpu/drm/mgag200/mgag200_g200se.c
drivers/gpu/drm/mgag200/mgag200_g200wb.c
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/mgag200/mgag200_reg.h

index f0fb132..1ceb19a 100644 (file)
@@ -200,6 +200,9 @@ struct mgag200_device_info {
         */
        unsigned long max_mem_bandwidth;
 
+       /* HW has external source (e.g., BMC) to synchronize with */
+       bool has_vidrst:1;
+
        /*
         * HW does not handle 'startadd' register correctly. Always set
         * it's value to 0.
@@ -208,11 +211,12 @@ struct mgag200_device_info {
 };
 
 #define MGAG200_DEVICE_INFO_INIT(_max_hdisplay, _max_vdisplay, _max_mem_bandwidth, \
-                                _bug_no_startadd) \
+                                _has_vidrst, _bug_no_startadd) \
        { \
                .max_hdisplay = (_max_hdisplay), \
                .max_vdisplay = (_max_vdisplay), \
                .max_mem_bandwidth = (_max_mem_bandwidth), \
+               .has_vidrst = (_has_vidrst), \
                .bug_no_startadd = (_bug_no_startadd), \
        }
 
index 4ec1b18..58ae5d0 100644 (file)
@@ -34,7 +34,7 @@ static int mgag200_g200_init_pci_options(struct pci_dev *pdev)
  */
 
 static const struct mgag200_device_info mgag200_g200_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false, false);
 
 static void mgag200_g200_interpret_bios(struct mgag200_g200_device *g200,
                                        const unsigned char *bios, size_t size)
index a35ba2f..ee38d91 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 static const struct mgag200_device_info mgag200_g200eh_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 37500, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 37500, false, false);
 
 struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
                                                enum mga_type type)
index 649559b..4b69206 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 static const struct mgag200_device_info mgag200_g200eh3_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false, false);
 
 struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev,
                                                 const struct drm_driver *drv,
index e661fad..7e44fcc 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 static const struct mgag200_device_info mgag200_g200er_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false, false);
 
 struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
                                                enum mga_type type)
index 07a3862..87a9497 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 static const struct mgag200_device_info mgag200_g200ev_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 32700, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 32700, false, false);
 
 struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
                                                enum mga_type type)
index 7f39874..61f9443 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 static const struct mgag200_device_info mgag200_g200ew3_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, false);
 
 static resource_size_t mgag200_g200ew3_device_probe_vram(struct mga_device *mdev)
 {
index 7812047..0ccec93 100644 (file)
@@ -33,22 +33,22 @@ static int mgag200_g200se_init_pci_options(struct pci_dev *pdev)
  */
 
 static const struct mgag200_device_info mgag200_g200se_a_01_device_info =
-       MGAG200_DEVICE_INFO_INIT(1600, 1200, 24400, true);
+       MGAG200_DEVICE_INFO_INIT(1600, 1200, 24400, false, true);
 
 static const struct mgag200_device_info mgag200_g200se_a_02_device_info =
-       MGAG200_DEVICE_INFO_INIT(1920, 1200, 30100, true);
+       MGAG200_DEVICE_INFO_INIT(1920, 1200, 30100, false, true);
 
 static const struct mgag200_device_info mgag200_g200se_a_03_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false, false);
 
 static const struct mgag200_device_info mgag200_g200se_b_01_device_info =
-       MGAG200_DEVICE_INFO_INIT(1600, 1200, 24400, false);
+       MGAG200_DEVICE_INFO_INIT(1600, 1200, 24400, false, false);
 
 static const struct mgag200_device_info mgag200_g200se_b_02_device_info =
-       MGAG200_DEVICE_INFO_INIT(1920, 1200, 30100, false);
+       MGAG200_DEVICE_INFO_INIT(1920, 1200, 30100, false, false);
 
 static const struct mgag200_device_info mgag200_g200se_b_03_device_info =
-       MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false);
+       MGAG200_DEVICE_INFO_INIT(2048, 2048, 55000, false, false);
 
 static int mgag200_g200se_init_unique_rev_id(struct mgag200_g200se_device *g200se)
 {
index 0943ad2..97002c0 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 static const struct mgag200_device_info mgag200_g200wb_device_info =
-       MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, false);
+       MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, false);
 
 struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const struct drm_driver *drv,
                                                enum mga_type type)
index aa85558..e339f50 100644 (file)
@@ -377,6 +377,7 @@ static void mgag200_init_regs(struct mga_device *mdev)
 static void mgag200_set_mode_regs(struct mga_device *mdev,
                                  const struct drm_display_mode *mode)
 {
+       const struct mgag200_device_info *info = mdev->info;
        unsigned int hdisplay, hsyncstart, hsyncend, htotal;
        unsigned int vdisplay, vsyncstart, vsyncend, vtotal;
        u8 misc, crtcext1, crtcext2, crtcext5;
@@ -411,9 +412,9 @@ static void mgag200_set_mode_regs(struct mga_device *mdev,
                   ((hdisplay & 0x100) >> 7) |
                   ((hsyncstart & 0x100) >> 6) |
                    (htotal & 0x40);
-       if (mdev->type == G200_WB || mdev->type == G200_EW3)
-               crtcext1 |= BIT(7) | /* vrsten */
-                           BIT(3); /* hrsten */
+       if (info->has_vidrst)
+               crtcext1 |= MGAREG_CRTCEXT1_VRSTEN |
+                           MGAREG_CRTCEXT1_HRSTEN;
 
        crtcext2 = ((vtotal & 0xc00) >> 10) |
                   ((vdisplay & 0x400) >> 8) |
index 60e7052..99a9ab7 100644 (file)
 
 #define MGAREG_CRTCEXT0_OFFSET_MASK    GENMASK(5, 4)
 
+#define MGAREG_CRTCEXT1_VRSTEN         BIT(7)
 #define MGAREG_CRTCEXT1_VSYNCOFF       BIT(5)
 #define MGAREG_CRTCEXT1_HSYNCOFF       BIT(4)
+#define MGAREG_CRTCEXT1_HRSTEN         BIT(3)
 
 #define MGAREG_CRTCEXT3_MGAMODE                BIT(7)