Skip to content

Commit 72d45a7

Browse files
committed
Merge tag 'omapdrm-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux into drm-next
omapdrm fixes for 4.14 * fix compilation when compiling omapfb driver * WA for OMAP3 endless sync lost issue * WA for OMAP5 DSI PLL issue * fix analog TV out modecheck * tag 'omapdrm-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux: ARM: OMAP2+: fix missing variable declaration drm/omap: work-around for omap3 display enable drm/omap: fix i886 work-around drm/omap: fix analog tv-out modecheck
2 parents cfcfb65 + d1bbc82 commit 72d45a7

6 files changed

Lines changed: 107 additions & 40 deletions

File tree

‎arch/arm/mach-omap2/display.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static int __init omapdss_init_fbdev(void)
172172
.set_min_bus_tput = omap_dss_set_min_bus_tput,
173173
};
174174
struct device_node *node;
175+
int r;
175176

176177
board_data.version = omap_display_get_version();
177178
if (board_data.version == OMAPDSS_VER_UNKNOWN) {

‎drivers/gpu/drm/omapdrm/dss/dss.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ struct dss_pll_hw {
185185
bool has_freqsel;
186186
bool has_selfreqdco;
187187
bool has_refsel;
188+
189+
/* DRA7 errata i886: use high N & M to avoid jitter */
190+
bool errata_i886;
188191
};
189192

190193
struct dss_pll {

‎drivers/gpu/drm/omapdrm/dss/pll.c‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
215215
dss_pll_calc_func func, void *data)
216216
{
217217
const struct dss_pll_hw *hw = pll->hw;
218-
int n, n_min, n_max;
219-
int m, m_min, m_max;
218+
int n, n_start, n_stop, n_inc;
219+
int m, m_start, m_stop, m_inc;
220220
unsigned long fint, clkdco;
221221
unsigned long pll_hw_max;
222222
unsigned long fint_hw_min, fint_hw_max;
@@ -226,22 +226,33 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
226226
fint_hw_min = hw->fint_min;
227227
fint_hw_max = hw->fint_max;
228228

229-
n_min = max(DIV_ROUND_UP(clkin, fint_hw_max), 1ul);
230-
n_max = min((unsigned)(clkin / fint_hw_min), hw->n_max);
229+
n_start = max(DIV_ROUND_UP(clkin, fint_hw_max), 1ul);
230+
n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
231+
n_inc = 1;
232+
233+
if (hw->errata_i886) {
234+
swap(n_start, n_stop);
235+
n_inc = -1;
236+
}
231237

232238
pll_max = pll_max ? pll_max : ULONG_MAX;
233239

234-
/* Try to find high N & M to avoid jitter (DRA7 errata i886) */
235-
for (n = n_max; n >= n_min; --n) {
240+
for (n = n_start; n != n_stop; n += n_inc) {
236241
fint = clkin / n;
237242

238-
m_min = max(DIV_ROUND_UP(DIV_ROUND_UP(pll_min, fint), 2),
243+
m_start = max(DIV_ROUND_UP(DIV_ROUND_UP(pll_min, fint), 2),
239244
1ul);
240-
m_max = min3((unsigned)(pll_max / fint / 2),
245+
m_stop = min3((unsigned)(pll_max / fint / 2),
241246
(unsigned)(pll_hw_max / fint / 2),
242247
hw->m_max);
248+
m_inc = 1;
249+
250+
if (hw->errata_i886) {
251+
swap(m_start, m_stop);
252+
m_inc = -1;
253+
}
243254

244-
for (m = m_max; m >= m_min; --m) {
255+
for (m = m_start; m != m_stop; m += m_inc) {
245256
clkdco = 2 * m * fint;
246257

247258
if (func(n, m, fint, clkdco, data))

‎drivers/gpu/drm/omapdrm/dss/venc.c‎

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ static const struct venc_config venc_config_pal_bdghi = {
263263
.fid_ext_start_y__fid_ext_offset_y = 0x01380005,
264264
};
265265

266+
enum venc_videomode {
267+
VENC_MODE_UNKNOWN,
268+
VENC_MODE_PAL,
269+
VENC_MODE_NTSC,
270+
};
271+
266272
static const struct videomode omap_dss_pal_vm = {
267273
.hactive = 720,
268274
.vactive = 574,
@@ -297,6 +303,24 @@ static const struct videomode omap_dss_ntsc_vm = {
297303
DISPLAY_FLAGS_SYNC_NEGEDGE,
298304
};
299305

306+
static enum venc_videomode venc_get_videomode(const struct videomode *vm)
307+
{
308+
if (!(vm->flags & DISPLAY_FLAGS_INTERLACED))
309+
return VENC_MODE_UNKNOWN;
310+
311+
if (vm->pixelclock == omap_dss_pal_vm.pixelclock &&
312+
vm->hactive == omap_dss_pal_vm.hactive &&
313+
vm->vactive == omap_dss_pal_vm.vactive)
314+
return VENC_MODE_PAL;
315+
316+
if (vm->pixelclock == omap_dss_ntsc_vm.pixelclock &&
317+
vm->hactive == omap_dss_ntsc_vm.hactive &&
318+
vm->vactive == omap_dss_ntsc_vm.vactive)
319+
return VENC_MODE_NTSC;
320+
321+
return VENC_MODE_UNKNOWN;
322+
}
323+
300324
static struct {
301325
struct platform_device *pdev;
302326
void __iomem *base;
@@ -423,14 +447,14 @@ static void venc_runtime_put(void)
423447

424448
static const struct venc_config *venc_timings_to_config(struct videomode *vm)
425449
{
426-
if (memcmp(&omap_dss_pal_vm, vm, sizeof(*vm)) == 0)
450+
switch (venc_get_videomode(vm)) {
451+
default:
452+
WARN_ON_ONCE(1);
453+
case VENC_MODE_PAL:
427454
return &venc_config_pal_trm;
428-
429-
if (memcmp(&omap_dss_ntsc_vm, vm, sizeof(*vm)) == 0)
455+
case VENC_MODE_NTSC:
430456
return &venc_config_ntsc_trm;
431-
432-
BUG();
433-
return NULL;
457+
}
434458
}
435459

436460
static int venc_power_on(struct omap_dss_device *dssdev)
@@ -541,15 +565,28 @@ static void venc_display_disable(struct omap_dss_device *dssdev)
541565
static void venc_set_timings(struct omap_dss_device *dssdev,
542566
struct videomode *vm)
543567
{
568+
struct videomode actual_vm;
569+
544570
DSSDBG("venc_set_timings\n");
545571

546572
mutex_lock(&venc.venc_lock);
547573

574+
switch (venc_get_videomode(vm)) {
575+
default:
576+
WARN_ON_ONCE(1);
577+
case VENC_MODE_PAL:
578+
actual_vm = omap_dss_pal_vm;
579+
break;
580+
case VENC_MODE_NTSC:
581+
actual_vm = omap_dss_ntsc_vm;
582+
break;
583+
}
584+
548585
/* Reset WSS data when the TV standard changes. */
549-
if (memcmp(&venc.vm, vm, sizeof(*vm)))
586+
if (memcmp(&venc.vm, &actual_vm, sizeof(actual_vm)))
550587
venc.wss_data = 0;
551588

552-
venc.vm = *vm;
589+
venc.vm = actual_vm;
553590

554591
dispc_set_tv_pclk(13500000);
555592

@@ -561,13 +598,13 @@ static int venc_check_timings(struct omap_dss_device *dssdev,
561598
{
562599
DSSDBG("venc_check_timings\n");
563600

564-
if (memcmp(&omap_dss_pal_vm, vm, sizeof(*vm)) == 0)
601+
switch (venc_get_videomode(vm)) {
602+
case VENC_MODE_PAL:
603+
case VENC_MODE_NTSC:
565604
return 0;
566-
567-
if (memcmp(&omap_dss_ntsc_vm, vm, sizeof(*vm)) == 0)
568-
return 0;
569-
570-
return -EINVAL;
605+
default:
606+
return -EINVAL;
607+
}
571608
}
572609

573610
static void venc_get_timings(struct omap_dss_device *dssdev,

‎drivers/gpu/drm/omapdrm/dss/video-pll.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ static const struct dss_pll_hw dss_dra7_video_pll_hw = {
130130
.mX_lsb[3] = 5,
131131

132132
.has_refsel = true,
133+
134+
.errata_i886 = true,
133135
};
134136

135137
struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,

‎drivers/gpu/drm/omapdrm/omap_drv.c‎

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,36 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
8484
/* Apply the atomic update. */
8585
drm_atomic_helper_commit_modeset_disables(dev, old_state);
8686

87-
/* With the current dss dispc implementation we have to enable
88-
* the new modeset before we can commit planes. The dispc ovl
89-
* configuration relies on the video mode configuration been
90-
* written into the HW when the ovl configuration is
91-
* calculated.
92-
*
93-
* This approach is not ideal because after a mode change the
94-
* plane update is executed only after the first vblank
95-
* interrupt. The dispc implementation should be fixed so that
96-
* it is able use uncommitted drm state information.
97-
*/
98-
drm_atomic_helper_commit_modeset_enables(dev, old_state);
99-
omap_atomic_wait_for_completion(dev, old_state);
100-
101-
drm_atomic_helper_commit_planes(dev, old_state, 0);
102-
103-
drm_atomic_helper_commit_hw_done(old_state);
87+
if (priv->omaprev != 0x3430) {
88+
/* With the current dss dispc implementation we have to enable
89+
* the new modeset before we can commit planes. The dispc ovl
90+
* configuration relies on the video mode configuration been
91+
* written into the HW when the ovl configuration is
92+
* calculated.
93+
*
94+
* This approach is not ideal because after a mode change the
95+
* plane update is executed only after the first vblank
96+
* interrupt. The dispc implementation should be fixed so that
97+
* it is able use uncommitted drm state information.
98+
*/
99+
drm_atomic_helper_commit_modeset_enables(dev, old_state);
100+
omap_atomic_wait_for_completion(dev, old_state);
101+
102+
drm_atomic_helper_commit_planes(dev, old_state, 0);
103+
104+
drm_atomic_helper_commit_hw_done(old_state);
105+
} else {
106+
/*
107+
* OMAP3 DSS seems to have issues with the work-around above,
108+
* resulting in endless sync losts if a crtc is enabled without
109+
* a plane. For now, skip the WA for OMAP3.
110+
*/
111+
drm_atomic_helper_commit_planes(dev, old_state, 0);
112+
113+
drm_atomic_helper_commit_modeset_enables(dev, old_state);
114+
115+
drm_atomic_helper_commit_hw_done(old_state);
116+
}
104117

105118
/*
106119
* Wait for completion of the page flips to ensure that old buffers

0 commit comments

Comments
 (0)