Skip to content

Commit b46cab6

Browse files
njhollinghurstpopcornmix
authored andcommitted
drm: rp1: rp1-dpi: Fix optional dependency on RP1_PIO
Add optional dependency to Kconfig, and conditionally compile PIO-dependent code. Add a mode validation function to reject interlaced modes when RP1_PIO is not present. Signed-off-by: Nick Hollinghurst <[email protected]>
1 parent 98b15e9 commit b46cab6

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

drivers/gpu/drm/rp1/rp1-dpi/Kconfig

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@ config DRM_RP1_DPI
77
select DRM_VRAM_HELPER
88
select DRM_TTM
99
select DRM_TTM_HELPER
10+
depends on RP1_PIO || !RP1_PIO
1011
help
11-
Choose this option to enable Video Out on RP1
12+
Choose this option to enable DPI output on Raspberry Pi RP1
13+
14+
There is an optional dependency on RP1_PIO, as the PIO block
15+
must be used to fix up interlaced sync. Interlaced DPI modes
16+
will be unavailable when RP1_PIO is not selected.

drivers/gpu/drm/rp1/rp1-dpi/rp1_dpi.c

+16
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,28 @@ static void rp1dpi_pipe_disable_vblank(struct drm_simple_display_pipe *pipe)
217217
rp1dpi_hw_vblank_ctrl(dpi, 0);
218218
}
219219

220+
static enum drm_mode_status rp1dpi_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
221+
const struct drm_display_mode *mode)
222+
{
223+
#if !IS_REACHABLE(CONFIG_RP1_PIO)
224+
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
225+
return MODE_NO_INTERLACE;
226+
#endif
227+
if (mode->clock < 1000) /* 1 MHz */
228+
return MODE_CLOCK_LOW;
229+
if (mode->clock > 200000) /* 200 MHz */
230+
return MODE_CLOCK_HIGH;
231+
232+
return MODE_OK;
233+
}
234+
220235
static const struct drm_simple_display_pipe_funcs rp1dpi_pipe_funcs = {
221236
.enable = rp1dpi_pipe_enable,
222237
.update = rp1dpi_pipe_update,
223238
.disable = rp1dpi_pipe_disable,
224239
.enable_vblank = rp1dpi_pipe_enable_vblank,
225240
.disable_vblank = rp1dpi_pipe_disable_vblank,
241+
.mode_valid = rp1dpi_pipe_mode_valid,
226242
};
227243

228244
static const struct drm_mode_config_funcs rp1dpi_mode_funcs = {

drivers/gpu/drm/rp1/rp1-dpi/rp1_dpi_pio.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
#include <linux/kernel.h>
1919
#include <linux/errno.h>
2020
#include <linux/of.h>
21-
#include <linux/pio_rp1.h>
2221
#include <linux/pinctrl/consumer.h>
2322
#include <linux/platform_device.h>
2423
#include <drm/drm_print.h>
2524

2625
#include "rp1_dpi.h"
2726

27+
#if IS_REACHABLE(CONFIG_RP1_PIO)
28+
29+
#include <linux/pio_rp1.h>
30+
2831
/*
2932
* Start a PIO SM to generate an interrupt just after HSYNC onset, then another
3033
* after a fixed delay (during which we assume HSYNC will have been deasserted).
@@ -223,3 +226,16 @@ void rp1dpi_pio_stop(struct rp1_dpi *dpi)
223226
dpi->pio = NULL;
224227
}
225228
}
229+
230+
#else /* !IS_REACHABLE(CONFIG_RP1_PIO) */
231+
232+
int rp1dpi_pio_start(struct rp1_dpi *dpi, const struct drm_display_mode *mode)
233+
{
234+
return -ENODEV;
235+
}
236+
237+
void rp1dpi_pio_stop(struct rp1_dpi *dpi)
238+
{
239+
}
240+
241+
#endif

0 commit comments

Comments
 (0)