Skip to content

Commit a87c8a1

Browse files
authored
Merge pull request #138 from maximschwalm/drm/tegra
drm/tegra: rgb: Parameterize signal polarities
2 parents 6b58478 + 89de49f commit a87c8a1

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

drivers/gpu/drm/tegra/dc.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,15 @@ int tegra_dc_rgb_exit(struct tegra_dc *dc);
269269
#define DC_COM_CRC_CONTROL_ENABLE (1 << 0)
270270
#define DC_COM_CRC_CHECKSUM 0x301
271271
#define DC_COM_PIN_OUTPUT_ENABLE(x) (0x302 + (x))
272+
272273
#define DC_COM_PIN_OUTPUT_POLARITY(x) (0x306 + (x))
273-
#define LVS_OUTPUT_POLARITY_LOW (1 << 28)
274-
#define LHS_OUTPUT_POLARITY_LOW (1 << 30)
274+
/* DC_COM_PIN_OUTPUT_POLARITY(1) bits */
275+
#define LHS_OUTPUT_POLARITY_LOW (1 << 30)
276+
#define LVS_OUTPUT_POLARITY_LOW (1 << 28)
277+
#define LSC0_OUTPUT_POLARITY_LOW (1 << 24)
278+
/* DC_COM_PIN_OUTPUT_POLARITY(3) bits */
279+
#define LSPI_OUTPUT_POLARITY_LOW (1 << 8)
280+
275281
#define DC_COM_PIN_OUTPUT_DATA(x) (0x30a + (x))
276282
#define DC_COM_PIN_INPUT_ENABLE(x) (0x30e + (x))
277283
#define DC_COM_PIN_INPUT_DATA(x) (0x312 + (x))

drivers/gpu/drm/tegra/rgb.c

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

100100
static 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

Comments
 (0)