viafb: add new output device management
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Tue, 10 Aug 2010 02:44:44 +0000 (02:44 +0000)
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Fri, 24 Sep 2010 02:14:50 +0000 (02:14 +0000)
This patch adds a new output device management that stores for each
IGA which output devices are routed to it and a compatiblity layer
that converts the old per-output device values in the new format.
Bounding the output devices to each IGA is a central idea of the
cleanup. Doing it this way should be easier and make much more sense
than the old format which happily mixed different output devices
together and did not even take into account that some devices are no
longer available on newer chipsets.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
drivers/video/via/hw.c
drivers/video/via/hw.h
drivers/video/via/viafbdev.h

index 638cf96c87397a1e92fb480ea5c8e848155fe8a9..30cc2f0961e312690441c748af44d56a0ab161c4 100644 (file)
@@ -753,6 +753,66 @@ void write_dac_reg(u8 index, u8 r, u8 g, u8 b)
        outb(b, LUT_DATA);
 }
 
+static u32 get_dvi_devices(int output_interface)
+{
+       switch (output_interface) {
+       case INTERFACE_DVP0:
+               return VIA_96 | VIA_6C;
+
+       case INTERFACE_DVP1:
+               if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
+                       return VIA_93;
+               else
+                       return VIA_DVP1;
+
+       case INTERFACE_DFP_HIGH:
+               if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
+                       return 0;
+               else
+                       return VIA_LVDS2 | VIA_96;
+
+       case INTERFACE_DFP_LOW:
+               if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
+                       return 0;
+               else
+                       return VIA_DVP1 | VIA_LVDS1;
+
+       case INTERFACE_TMDS:
+               return VIA_LVDS1;
+       }
+
+       return 0;
+}
+
+static u32 get_lcd_devices(int output_interface)
+{
+       switch (output_interface) {
+       case INTERFACE_DVP0:
+               return VIA_96;
+
+       case INTERFACE_DVP1:
+               return VIA_DVP1;
+
+       case INTERFACE_DFP_HIGH:
+               return VIA_LVDS2 | VIA_96;
+
+       case INTERFACE_DFP_LOW:
+               return VIA_LVDS1 | VIA_DVP1;
+
+       case INTERFACE_DFP:
+               return VIA_LVDS1 | VIA_LVDS2;
+
+       case INTERFACE_LVDS0:
+       case INTERFACE_LVDS0LVDS1:
+               return VIA_LVDS1;
+
+       case INTERFACE_LVDS1:
+               return VIA_LVDS2;
+       }
+
+       return 0;
+}
+
 /*Set IGA path for each device*/
 void viafb_set_iga_path(void)
 {
@@ -819,6 +879,48 @@ void viafb_set_iga_path(void)
                        viaparinfo->tmds_setting_info->iga_path = IGA1;
                }
        }
+
+       viaparinfo->shared->iga1_devices = 0;
+       viaparinfo->shared->iga2_devices = 0;
+       if (viafb_CRT_ON) {
+               if (viaparinfo->crt_setting_info->iga_path == IGA1)
+                       viaparinfo->shared->iga1_devices |= VIA_CRT;
+               else
+                       viaparinfo->shared->iga2_devices |= VIA_CRT;
+       }
+
+       if (viafb_DVI_ON) {
+               if (viaparinfo->tmds_setting_info->iga_path == IGA1)
+                       viaparinfo->shared->iga1_devices |= get_dvi_devices(
+                               viaparinfo->chip_info->
+                               tmds_chip_info.output_interface);
+               else
+                       viaparinfo->shared->iga2_devices |= get_dvi_devices(
+                               viaparinfo->chip_info->
+                               tmds_chip_info.output_interface);
+       }
+
+       if (viafb_LCD_ON) {
+               if (viaparinfo->lvds_setting_info->iga_path == IGA1)
+                       viaparinfo->shared->iga1_devices |= get_lcd_devices(
+                               viaparinfo->chip_info->
+                               lvds_chip_info.output_interface);
+               else
+                       viaparinfo->shared->iga2_devices |= get_lcd_devices(
+                               viaparinfo->chip_info->
+                               lvds_chip_info.output_interface);
+       }
+
+       if (viafb_LCD2_ON) {
+               if (viaparinfo->lvds_setting_info2->iga_path == IGA1)
+                       viaparinfo->shared->iga1_devices |= get_lcd_devices(
+                               viaparinfo->chip_info->
+                               lvds_chip_info2.output_interface);
+               else
+                       viaparinfo->shared->iga2_devices |= get_lcd_devices(
+                               viaparinfo->chip_info->
+                               lvds_chip_info2.output_interface);
+       }
 }
 
 static void set_color_register(u8 index, u8 red, u8 green, u8 blue)
index 39f3a69bbbd881bf3dbe158a42b9c7ade6d210eb..c52a1d5f092d42596e965daeca23710bdf9dab97 100644 (file)
 #define viafb_write_reg(i, p, d)               via_write_reg(p, i, d)
 #define viafb_write_reg_mask(i, p, d, m)       via_write_reg_mask(p, i, d, m)
 
+/* VIA output devices */
+#define VIA_6C         0x00000001
+#define VIA_93         0x00000002
+#define VIA_96         0x00000004
+#define VIA_CRT                0x00000010
+#define VIA_DVP1       0x00000020
+#define VIA_LVDS1      0x00000040
+#define VIA_LVDS2      0x00000080
+
 /***************************************************
 * Definition IGA1 Design Method of CRTC Registers *
 ****************************************************/
index 52a35fabba91dfbbb8e35c79e6dc79ab96915ba9..945a47a63c4d6029918aeffa8e687b8002ec94ac 100644 (file)
@@ -40,6 +40,9 @@
 #define VIAFB_NUM_I2C          5
 
 struct viafb_shared {
+       u32 iga1_devices;
+       u32 iga2_devices;
+
        struct proc_dir_entry *proc_entry;      /*viafb proc entry */
        struct viafb_dev *vdev;                 /* Global dev info */