@@ -34,7 +34,7 @@ struct reg_entry {
3434 unsigned long value ;
3535};
3636
37- static struct reg_entry rgb_enable [] = {
37+ static const struct reg_entry rgb_enable [] = {
3838 { DC_COM_PIN_OUTPUT_ENABLE (0 ), 0x00000000 },
3939 { DC_COM_PIN_OUTPUT_ENABLE (1 ), 0x00000000 },
4040 { DC_COM_PIN_OUTPUT_ENABLE (2 ), 0x00000000 },
@@ -99,34 +99,51 @@ static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
9999
100100static void tegra_rgb_encoder_enable (struct drm_encoder * encoder )
101101{
102+ struct drm_display_mode * mode = & encoder -> crtc -> state -> adjusted_mode ;
102103 struct tegra_output * output = encoder_to_output (encoder );
104+ struct drm_connector * connector = drm_panel_bridge_connector (output -> bridge );
103105 struct tegra_rgb * rgb = to_rgb (output );
104106 u32 value ;
105107
106- /*
107- * Temporal hack for S6E63M0
108- *
109- * Pins DATA_ENABLE, H_SYNC, V_SYNC, PIXEL_CLOCK are low polarity,
110- * set this in the registers to make the panel working.
111- */
112- if (of_machine_is_compatible ("samsung,i927" ))
113- rgb_enable [7 ].value = 0x00000100 ;
114-
115108 tegra_dc_write_regs (rgb -> dc , rgb_enable , ARRAY_SIZE (rgb_enable ));
116109
117110 value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL ;
118111 tegra_dc_writel (rgb -> dc , value , DC_DISP_DATA_ENABLE_OPTIONS );
119112
120- /* XXX: parameterize? */
113+ /* configure H- and V-sync and pixel clock signal polarities */
121114 value = tegra_dc_readl (rgb -> dc , DC_COM_PIN_OUTPUT_POLARITY (1 ));
122- value &= ~LVS_OUTPUT_POLARITY_LOW ;
123- value &= ~LHS_OUTPUT_POLARITY_LOW ;
124- if (of_machine_is_compatible ("samsung,i927" )) {
125- value |= LVS_OUTPUT_POLARITY_LOW ;
115+
116+ if (mode -> flags & DRM_MODE_FLAG_PHSYNC )
117+ value &= ~LHS_OUTPUT_POLARITY_LOW ;
118+
119+ if (mode -> flags & DRM_MODE_FLAG_NHSYNC )
126120 value |= LHS_OUTPUT_POLARITY_LOW ;
127- }
121+
122+ if (mode -> flags & DRM_MODE_FLAG_PVSYNC )
123+ value &= ~LVS_OUTPUT_POLARITY_LOW ;
124+
125+ if (mode -> flags & DRM_MODE_FLAG_NVSYNC )
126+ value |= LVS_OUTPUT_POLARITY_LOW ;
127+
128+ if (connector -> display_info .bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE )
129+ value &= ~LSC0_OUTPUT_POLARITY_LOW ;
130+
131+ if (connector -> display_info .bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE )
132+ value |= LSC0_OUTPUT_POLARITY_LOW ;
133+
128134 tegra_dc_writel (rgb -> dc , value , DC_COM_PIN_OUTPUT_POLARITY (1 ));
129135
136+ /* configure DE signal polarities */
137+ value = tegra_dc_readl (rgb -> dc , DC_COM_PIN_OUTPUT_POLARITY (3 ));
138+
139+ if (connector -> display_info .bus_flags & DRM_BUS_FLAG_DE_HIGH )
140+ value &= ~LSPI_OUTPUT_POLARITY_LOW ;
141+
142+ if (connector -> display_info .bus_flags & DRM_BUS_FLAG_DE_LOW )
143+ value |= LSPI_OUTPUT_POLARITY_LOW ;
144+
145+ tegra_dc_writel (rgb -> dc , value , DC_COM_PIN_OUTPUT_POLARITY (3 ));
146+
130147 /* XXX: parameterize? */
131148 if (of_machine_is_compatible ("samsung,i927" )) {
132149 /* Set DISP_COLOR_SWAP bit to swap red and blue colors */
0 commit comments