1 // SPDX-License-Identifier: GPL-2.0+
3 * rcar_du_kms.c -- R-Car Display Unit Mode Setting
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
10 #include <drm/drm_atomic.h>
11 #include <drm/drm_atomic_helper.h>
12 #include <drm/drm_crtc.h>
13 #include <drm/drm_device.h>
14 #include <drm/drm_fb_cma_helper.h>
15 #include <drm/drm_gem_cma_helper.h>
16 #include <drm/drm_gem_framebuffer_helper.h>
17 #include <drm/drm_probe_helper.h>
18 #include <drm/drm_vblank.h>
20 #include <linux/device.h>
21 #include <linux/of_graph.h>
22 #include <linux/of_platform.h>
23 #include <linux/wait.h>
25 #include "rcar_du_crtc.h"
26 #include "rcar_du_drv.h"
27 #include "rcar_du_encoder.h"
28 #include "rcar_du_kms.h"
29 #include "rcar_du_regs.h"
30 #include "rcar_du_vsp.h"
31 #include "rcar_du_writeback.h"
33 /* -----------------------------------------------------------------------------
37 static const struct rcar_du_format_info rcar_du_format_infos
[] = {
39 .fourcc
= DRM_FORMAT_RGB565
,
40 .v4l2
= V4L2_PIX_FMT_RGB565
,
43 .pnmr
= PnMR_SPIM_TP
| PnMR_DDDF_16BPP
,
44 .edf
= PnDDCR4_EDF_NONE
,
46 .fourcc
= DRM_FORMAT_ARGB1555
,
47 .v4l2
= V4L2_PIX_FMT_ARGB555
,
50 .pnmr
= PnMR_SPIM_ALP
| PnMR_DDDF_ARGB
,
51 .edf
= PnDDCR4_EDF_NONE
,
53 .fourcc
= DRM_FORMAT_XRGB1555
,
54 .v4l2
= V4L2_PIX_FMT_XRGB555
,
57 .pnmr
= PnMR_SPIM_ALP
| PnMR_DDDF_ARGB
,
58 .edf
= PnDDCR4_EDF_NONE
,
60 .fourcc
= DRM_FORMAT_XRGB8888
,
61 .v4l2
= V4L2_PIX_FMT_XBGR32
,
64 .pnmr
= PnMR_SPIM_TP
| PnMR_DDDF_16BPP
,
65 .edf
= PnDDCR4_EDF_RGB888
,
67 .fourcc
= DRM_FORMAT_ARGB8888
,
68 .v4l2
= V4L2_PIX_FMT_ABGR32
,
71 .pnmr
= PnMR_SPIM_ALP
| PnMR_DDDF_16BPP
,
72 .edf
= PnDDCR4_EDF_ARGB8888
,
74 .fourcc
= DRM_FORMAT_UYVY
,
75 .v4l2
= V4L2_PIX_FMT_UYVY
,
78 .pnmr
= PnMR_SPIM_TP_OFF
| PnMR_DDDF_YC
,
79 .edf
= PnDDCR4_EDF_NONE
,
81 .fourcc
= DRM_FORMAT_YUYV
,
82 .v4l2
= V4L2_PIX_FMT_YUYV
,
85 .pnmr
= PnMR_SPIM_TP_OFF
| PnMR_DDDF_YC
,
86 .edf
= PnDDCR4_EDF_NONE
,
88 .fourcc
= DRM_FORMAT_NV12
,
89 .v4l2
= V4L2_PIX_FMT_NV12M
,
92 .pnmr
= PnMR_SPIM_TP_OFF
| PnMR_DDDF_YC
,
93 .edf
= PnDDCR4_EDF_NONE
,
95 .fourcc
= DRM_FORMAT_NV21
,
96 .v4l2
= V4L2_PIX_FMT_NV21M
,
99 .pnmr
= PnMR_SPIM_TP_OFF
| PnMR_DDDF_YC
,
100 .edf
= PnDDCR4_EDF_NONE
,
102 .fourcc
= DRM_FORMAT_NV16
,
103 .v4l2
= V4L2_PIX_FMT_NV16M
,
106 .pnmr
= PnMR_SPIM_TP_OFF
| PnMR_DDDF_YC
,
107 .edf
= PnDDCR4_EDF_NONE
,
110 * The following formats are not supported on Gen2 and thus have no
111 * associated .pnmr or .edf settings.
114 .fourcc
= DRM_FORMAT_RGB332
,
115 .v4l2
= V4L2_PIX_FMT_RGB332
,
119 .fourcc
= DRM_FORMAT_ARGB4444
,
120 .v4l2
= V4L2_PIX_FMT_ARGB444
,
124 .fourcc
= DRM_FORMAT_XRGB4444
,
125 .v4l2
= V4L2_PIX_FMT_XRGB444
,
129 .fourcc
= DRM_FORMAT_RGBA4444
,
130 .v4l2
= V4L2_PIX_FMT_RGBA444
,
134 .fourcc
= DRM_FORMAT_RGBX4444
,
135 .v4l2
= V4L2_PIX_FMT_RGBX444
,
139 .fourcc
= DRM_FORMAT_ABGR4444
,
140 .v4l2
= V4L2_PIX_FMT_ABGR444
,
144 .fourcc
= DRM_FORMAT_XBGR4444
,
145 .v4l2
= V4L2_PIX_FMT_XBGR444
,
149 .fourcc
= DRM_FORMAT_BGRA4444
,
150 .v4l2
= V4L2_PIX_FMT_BGRA444
,
154 .fourcc
= DRM_FORMAT_BGRX4444
,
155 .v4l2
= V4L2_PIX_FMT_BGRX444
,
159 .fourcc
= DRM_FORMAT_RGBA5551
,
160 .v4l2
= V4L2_PIX_FMT_RGBA555
,
164 .fourcc
= DRM_FORMAT_RGBX5551
,
165 .v4l2
= V4L2_PIX_FMT_RGBX555
,
169 .fourcc
= DRM_FORMAT_ABGR1555
,
170 .v4l2
= V4L2_PIX_FMT_ABGR555
,
174 .fourcc
= DRM_FORMAT_XBGR1555
,
175 .v4l2
= V4L2_PIX_FMT_XBGR555
,
179 .fourcc
= DRM_FORMAT_BGRA5551
,
180 .v4l2
= V4L2_PIX_FMT_BGRA555
,
184 .fourcc
= DRM_FORMAT_BGRX5551
,
185 .v4l2
= V4L2_PIX_FMT_BGRX555
,
189 .fourcc
= DRM_FORMAT_BGR888
,
190 .v4l2
= V4L2_PIX_FMT_RGB24
,
194 .fourcc
= DRM_FORMAT_RGB888
,
195 .v4l2
= V4L2_PIX_FMT_BGR24
,
199 .fourcc
= DRM_FORMAT_RGBA8888
,
200 .v4l2
= V4L2_PIX_FMT_BGRA32
,
204 .fourcc
= DRM_FORMAT_RGBX8888
,
205 .v4l2
= V4L2_PIX_FMT_BGRX32
,
209 .fourcc
= DRM_FORMAT_ABGR8888
,
210 .v4l2
= V4L2_PIX_FMT_RGBA32
,
214 .fourcc
= DRM_FORMAT_XBGR8888
,
215 .v4l2
= V4L2_PIX_FMT_RGBX32
,
219 .fourcc
= DRM_FORMAT_BGRA8888
,
220 .v4l2
= V4L2_PIX_FMT_ARGB32
,
224 .fourcc
= DRM_FORMAT_BGRX8888
,
225 .v4l2
= V4L2_PIX_FMT_XRGB32
,
229 .fourcc
= DRM_FORMAT_YVYU
,
230 .v4l2
= V4L2_PIX_FMT_YVYU
,
234 .fourcc
= DRM_FORMAT_NV61
,
235 .v4l2
= V4L2_PIX_FMT_NV61M
,
239 .fourcc
= DRM_FORMAT_YUV420
,
240 .v4l2
= V4L2_PIX_FMT_YUV420M
,
244 .fourcc
= DRM_FORMAT_YVU420
,
245 .v4l2
= V4L2_PIX_FMT_YVU420M
,
249 .fourcc
= DRM_FORMAT_YUV422
,
250 .v4l2
= V4L2_PIX_FMT_YUV422M
,
254 .fourcc
= DRM_FORMAT_YVU422
,
255 .v4l2
= V4L2_PIX_FMT_YVU422M
,
259 .fourcc
= DRM_FORMAT_YUV444
,
260 .v4l2
= V4L2_PIX_FMT_YUV444M
,
264 .fourcc
= DRM_FORMAT_YVU444
,
265 .v4l2
= V4L2_PIX_FMT_YVU444M
,
271 const struct rcar_du_format_info
*rcar_du_format_info(u32 fourcc
)
275 for (i
= 0; i
< ARRAY_SIZE(rcar_du_format_infos
); ++i
) {
276 if (rcar_du_format_infos
[i
].fourcc
== fourcc
)
277 return &rcar_du_format_infos
[i
];
283 /* -----------------------------------------------------------------------------
287 int rcar_du_dumb_create(struct drm_file
*file
, struct drm_device
*dev
,
288 struct drm_mode_create_dumb
*args
)
290 struct rcar_du_device
*rcdu
= dev
->dev_private
;
291 unsigned int min_pitch
= DIV_ROUND_UP(args
->width
* args
->bpp
, 8);
295 * The R8A7779 DU requires a 16 pixels pitch alignment as documented,
296 * but the R8A7790 DU seems to require a 128 bytes pitch alignment.
298 if (rcar_du_needs(rcdu
, RCAR_DU_QUIRK_ALIGN_128B
))
301 align
= 16 * args
->bpp
/ 8;
303 args
->pitch
= roundup(min_pitch
, align
);
305 return drm_gem_cma_dumb_create_internal(file
, dev
, args
);
308 static struct drm_framebuffer
*
309 rcar_du_fb_create(struct drm_device
*dev
, struct drm_file
*file_priv
,
310 const struct drm_mode_fb_cmd2
*mode_cmd
)
312 struct rcar_du_device
*rcdu
= dev
->dev_private
;
313 const struct rcar_du_format_info
*format
;
314 unsigned int max_pitch
;
318 format
= rcar_du_format_info(mode_cmd
->pixel_format
);
319 if (format
== NULL
) {
320 dev_dbg(dev
->dev
, "unsupported pixel format %08x\n",
321 mode_cmd
->pixel_format
);
322 return ERR_PTR(-EINVAL
);
325 if (rcdu
->info
->gen
< 3) {
327 * On Gen2 the DU limits the pitch to 4095 pixels and requires
328 * buffers to be aligned to a 16 pixels boundary (or 128 bytes
329 * on some platforms).
331 unsigned int bpp
= format
->planes
== 1 ? format
->bpp
/ 8 : 1;
333 max_pitch
= 4095 * bpp
;
335 if (rcar_du_needs(rcdu
, RCAR_DU_QUIRK_ALIGN_128B
))
341 * On Gen3 the memory interface is handled by the VSP that
342 * limits the pitch to 65535 bytes and has no alignment
349 if (mode_cmd
->pitches
[0] & (align
- 1) ||
350 mode_cmd
->pitches
[0] > max_pitch
) {
351 dev_dbg(dev
->dev
, "invalid pitch value %u\n",
352 mode_cmd
->pitches
[0]);
353 return ERR_PTR(-EINVAL
);
356 for (i
= 1; i
< format
->planes
; ++i
) {
357 if (mode_cmd
->pitches
[i
] != mode_cmd
->pitches
[0]) {
359 "luma and chroma pitches do not match\n");
360 return ERR_PTR(-EINVAL
);
364 return drm_gem_fb_create(dev
, file_priv
, mode_cmd
);
367 /* -----------------------------------------------------------------------------
368 * Atomic Check and Update
371 static int rcar_du_atomic_check(struct drm_device
*dev
,
372 struct drm_atomic_state
*state
)
374 struct rcar_du_device
*rcdu
= dev
->dev_private
;
377 ret
= drm_atomic_helper_check(dev
, state
);
381 if (rcar_du_has(rcdu
, RCAR_DU_FEATURE_VSP1_SOURCE
))
384 return rcar_du_atomic_check_planes(dev
, state
);
387 static void rcar_du_atomic_commit_tail(struct drm_atomic_state
*old_state
)
389 struct drm_device
*dev
= old_state
->dev
;
390 struct rcar_du_device
*rcdu
= dev
->dev_private
;
391 struct drm_crtc_state
*crtc_state
;
392 struct drm_crtc
*crtc
;
396 * Store RGB routing to DPAD0 and DPAD1, the hardware will be configured
397 * when starting the CRTCs.
399 rcdu
->dpad1_source
= -1;
401 for_each_new_crtc_in_state(old_state
, crtc
, crtc_state
, i
) {
402 struct rcar_du_crtc_state
*rcrtc_state
=
403 to_rcar_crtc_state(crtc_state
);
404 struct rcar_du_crtc
*rcrtc
= to_rcar_crtc(crtc
);
406 if (rcrtc_state
->outputs
& BIT(RCAR_DU_OUTPUT_DPAD0
))
407 rcdu
->dpad0_source
= rcrtc
->index
;
409 if (rcrtc_state
->outputs
& BIT(RCAR_DU_OUTPUT_DPAD1
))
410 rcdu
->dpad1_source
= rcrtc
->index
;
413 /* Apply the atomic update. */
414 drm_atomic_helper_commit_modeset_disables(dev
, old_state
);
415 drm_atomic_helper_commit_planes(dev
, old_state
,
416 DRM_PLANE_COMMIT_ACTIVE_ONLY
);
417 drm_atomic_helper_commit_modeset_enables(dev
, old_state
);
419 drm_atomic_helper_commit_hw_done(old_state
);
420 drm_atomic_helper_wait_for_flip_done(dev
, old_state
);
422 drm_atomic_helper_cleanup_planes(dev
, old_state
);
425 /* -----------------------------------------------------------------------------
429 static const struct drm_mode_config_helper_funcs rcar_du_mode_config_helper
= {
430 .atomic_commit_tail
= rcar_du_atomic_commit_tail
,
433 static const struct drm_mode_config_funcs rcar_du_mode_config_funcs
= {
434 .fb_create
= rcar_du_fb_create
,
435 .atomic_check
= rcar_du_atomic_check
,
436 .atomic_commit
= drm_atomic_helper_commit
,
439 static int rcar_du_encoders_init_one(struct rcar_du_device
*rcdu
,
440 enum rcar_du_output output
,
441 struct of_endpoint
*ep
)
443 struct device_node
*entity
;
446 /* Locate the connected entity and initialize the encoder. */
447 entity
= of_graph_get_remote_port_parent(ep
->local_node
);
449 dev_dbg(rcdu
->dev
, "unconnected endpoint %pOF, skipping\n",
454 if (!of_device_is_available(entity
)) {
456 "connected entity %pOF is disabled, skipping\n",
462 ret
= rcar_du_encoder_init(rcdu
, output
, entity
);
463 if (ret
&& ret
!= -EPROBE_DEFER
&& ret
!= -ENOLINK
)
465 "failed to initialize encoder %pOF on output %u (%d), skipping\n",
466 entity
, output
, ret
);
473 static int rcar_du_encoders_init(struct rcar_du_device
*rcdu
)
475 struct device_node
*np
= rcdu
->dev
->of_node
;
476 struct device_node
*ep_node
;
477 unsigned int num_encoders
= 0;
480 * Iterate over the endpoints and create one encoder for each output
483 for_each_endpoint_of_node(np
, ep_node
) {
484 enum rcar_du_output output
;
485 struct of_endpoint ep
;
489 ret
= of_graph_parse_endpoint(ep_node
, &ep
);
491 of_node_put(ep_node
);
495 /* Find the output route corresponding to the port number. */
496 for (i
= 0; i
< RCAR_DU_OUTPUT_MAX
; ++i
) {
497 if (rcdu
->info
->routes
[i
].possible_crtcs
&&
498 rcdu
->info
->routes
[i
].port
== ep
.port
) {
504 if (i
== RCAR_DU_OUTPUT_MAX
) {
506 "port %u references unexisting output, skipping\n",
511 /* Process the output pipeline. */
512 ret
= rcar_du_encoders_init_one(rcdu
, output
, &ep
);
514 if (ret
== -EPROBE_DEFER
) {
515 of_node_put(ep_node
);
528 static int rcar_du_properties_init(struct rcar_du_device
*rcdu
)
531 * The color key is expressed as an RGB888 triplet stored in a 32-bit
532 * integer in XRGB8888 format. Bit 24 is used as a flag to disable (0)
533 * or enable source color keying (1).
535 rcdu
->props
.colorkey
=
536 drm_property_create_range(rcdu
->ddev
, 0, "colorkey",
538 if (rcdu
->props
.colorkey
== NULL
)
544 static int rcar_du_vsps_init(struct rcar_du_device
*rcdu
)
546 const struct device_node
*np
= rcdu
->dev
->of_node
;
547 const char *vsps_prop_name
= "renesas,vsps";
548 struct of_phandle_args args
;
550 struct device_node
*np
;
551 unsigned int crtcs_mask
;
552 } vsps
[RCAR_DU_MAX_VSPS
] = { { NULL
, }, };
553 unsigned int vsps_count
= 0;
559 * First parse the DT vsps property to populate the list of VSPs. Each
560 * entry contains a pointer to the VSP DT node and a bitmask of the
561 * connected DU CRTCs.
563 ret
= of_property_count_u32_elems(np
, vsps_prop_name
);
565 /* Backward compatibility with old DTBs. */
566 vsps_prop_name
= "vsps";
567 ret
= of_property_count_u32_elems(np
, vsps_prop_name
);
569 cells
= ret
/ rcdu
->num_crtcs
- 1;
573 for (i
= 0; i
< rcdu
->num_crtcs
; ++i
) {
576 ret
= of_parse_phandle_with_fixed_args(np
, vsps_prop_name
,
582 * Add the VSP to the list or update the corresponding existing
583 * entry if the VSP has already been added.
585 for (j
= 0; j
< vsps_count
; ++j
) {
586 if (vsps
[j
].np
== args
.np
)
591 of_node_put(args
.np
);
593 vsps
[vsps_count
++].np
= args
.np
;
595 vsps
[j
].crtcs_mask
|= BIT(i
);
598 * Store the VSP pointer and pipe index in the CRTC. If the
599 * second cell of the 'renesas,vsps' specifier isn't present,
600 * default to 0 to remain compatible with older DT bindings.
602 rcdu
->crtcs
[i
].vsp
= &rcdu
->vsps
[j
];
603 rcdu
->crtcs
[i
].vsp_pipe
= cells
>= 1 ? args
.args
[0] : 0;
607 * Then initialize all the VSPs from the node pointers and CRTCs bitmask
608 * computed previously.
610 for (i
= 0; i
< vsps_count
; ++i
) {
611 struct rcar_du_vsp
*vsp
= &rcdu
->vsps
[i
];
616 ret
= rcar_du_vsp_init(vsp
, vsps
[i
].np
, vsps
[i
].crtcs_mask
);
624 for (i
= 0; i
< ARRAY_SIZE(vsps
); ++i
)
625 of_node_put(vsps
[i
].np
);
630 static int rcar_du_cmm_init(struct rcar_du_device
*rcdu
)
632 const struct device_node
*np
= rcdu
->dev
->of_node
;
636 cells
= of_property_count_u32_elems(np
, "renesas,cmms");
637 if (cells
== -EINVAL
)
640 if (cells
> rcdu
->num_crtcs
) {
642 "Invalid number of entries in 'renesas,cmms'\n");
646 for (i
= 0; i
< cells
; ++i
) {
647 struct platform_device
*pdev
;
648 struct device_link
*link
;
649 struct device_node
*cmm
;
652 cmm
= of_parse_phandle(np
, "renesas,cmms", i
);
655 "Failed to parse 'renesas,cmms' property\n");
659 if (!of_device_is_available(cmm
)) {
660 /* It's fine to have a phandle to a non-enabled CMM. */
665 pdev
= of_find_device_by_node(cmm
);
667 dev_err(rcdu
->dev
, "No device found for CMM%u\n", i
);
669 return PTR_ERR(pdev
);
675 * -ENODEV is used to report that the CMM config option is
676 * disabled: return 0 and let the DU continue probing.
678 ret
= rcar_cmm_init(pdev
);
680 return ret
== -ENODEV
? 0 : ret
;
683 * Enforce suspend/resume ordering by making the CMM a provider
684 * of the DU: CMM is suspended after and resumed before the DU.
686 link
= device_link_add(rcdu
->dev
, &pdev
->dev
, DL_FLAG_STATELESS
);
689 "Failed to create device link to CMM%u\n", i
);
693 rcdu
->cmms
[i
] = pdev
;
699 int rcar_du_modeset_init(struct rcar_du_device
*rcdu
)
701 static const unsigned int mmio_offsets
[] = {
702 DU0_REG_OFFSET
, DU2_REG_OFFSET
705 struct drm_device
*dev
= rcdu
->ddev
;
706 struct drm_encoder
*encoder
;
707 unsigned int dpad0_sources
;
708 unsigned int num_encoders
;
709 unsigned int num_groups
;
710 unsigned int swindex
;
711 unsigned int hwindex
;
715 drm_mode_config_init(dev
);
717 dev
->mode_config
.min_width
= 0;
718 dev
->mode_config
.min_height
= 0;
719 dev
->mode_config
.normalize_zpos
= true;
720 dev
->mode_config
.funcs
= &rcar_du_mode_config_funcs
;
721 dev
->mode_config
.helper_private
= &rcar_du_mode_config_helper
;
723 if (rcdu
->info
->gen
< 3) {
724 dev
->mode_config
.max_width
= 4095;
725 dev
->mode_config
.max_height
= 2047;
728 * The Gen3 DU uses the VSP1 for memory access, and is limited
729 * to frame sizes of 8190x8190.
731 dev
->mode_config
.max_width
= 8190;
732 dev
->mode_config
.max_height
= 8190;
735 rcdu
->num_crtcs
= hweight8(rcdu
->info
->channels_mask
);
737 ret
= rcar_du_properties_init(rcdu
);
742 * Initialize vertical blanking interrupts handling. Start with vblank
743 * disabled for all CRTCs.
745 ret
= drm_vblank_init(dev
, rcdu
->num_crtcs
);
749 /* Initialize the groups. */
750 num_groups
= DIV_ROUND_UP(rcdu
->num_crtcs
, 2);
752 for (i
= 0; i
< num_groups
; ++i
) {
753 struct rcar_du_group
*rgrp
= &rcdu
->groups
[i
];
755 mutex_init(&rgrp
->lock
);
758 rgrp
->mmio_offset
= mmio_offsets
[i
];
760 /* Extract the channel mask for this group only. */
761 rgrp
->channels_mask
= (rcdu
->info
->channels_mask
>> (2 * i
))
763 rgrp
->num_crtcs
= hweight8(rgrp
->channels_mask
);
766 * If we have more than one CRTCs in this group pre-associate
767 * the low-order planes with CRTC 0 and the high-order planes
768 * with CRTC 1 to minimize flicker occurring when the
769 * association is changed.
771 rgrp
->dptsr_planes
= rgrp
->num_crtcs
> 1
772 ? (rcdu
->info
->gen
>= 3 ? 0x04 : 0xf0)
775 if (!rcar_du_has(rcdu
, RCAR_DU_FEATURE_VSP1_SOURCE
)) {
776 ret
= rcar_du_planes_init(rgrp
);
782 /* Initialize the compositors. */
783 if (rcar_du_has(rcdu
, RCAR_DU_FEATURE_VSP1_SOURCE
)) {
784 ret
= rcar_du_vsps_init(rcdu
);
789 /* Initialize the Color Management Modules. */
790 ret
= rcar_du_cmm_init(rcdu
);
794 /* Create the CRTCs. */
795 for (swindex
= 0, hwindex
= 0; swindex
< rcdu
->num_crtcs
; ++hwindex
) {
796 struct rcar_du_group
*rgrp
;
798 /* Skip unpopulated DU channels. */
799 if (!(rcdu
->info
->channels_mask
& BIT(hwindex
)))
802 rgrp
= &rcdu
->groups
[hwindex
/ 2];
804 ret
= rcar_du_crtc_create(rgrp
, swindex
++, hwindex
);
809 /* Initialize the encoders. */
810 ret
= rcar_du_encoders_init(rcdu
);
815 dev_err(rcdu
->dev
, "error: no encoder could be initialized\n");
822 * Set the possible CRTCs and possible clones. There's always at least
823 * one way for all encoders to clone each other, set all bits in the
824 * possible clones field.
826 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
827 struct rcar_du_encoder
*renc
= to_rcar_encoder(encoder
);
828 const struct rcar_du_output_routing
*route
=
829 &rcdu
->info
->routes
[renc
->output
];
831 encoder
->possible_crtcs
= route
->possible_crtcs
;
832 encoder
->possible_clones
= (1 << num_encoders
) - 1;
835 /* Create the writeback connectors. */
836 if (rcdu
->info
->gen
>= 3) {
837 for (i
= 0; i
< rcdu
->num_crtcs
; ++i
) {
838 struct rcar_du_crtc
*rcrtc
= &rcdu
->crtcs
[i
];
840 ret
= rcar_du_writeback_init(rcdu
, rcrtc
);
847 * Initialize the default DPAD0 source to the index of the first DU
848 * channel that can be connected to DPAD0. The exact value doesn't
849 * matter as it should be overwritten by mode setting for the RGB
850 * output, but it is nonetheless required to ensure a valid initial
851 * hardware configuration on Gen3 where DU0 can't always be connected to
854 dpad0_sources
= rcdu
->info
->routes
[RCAR_DU_OUTPUT_DPAD0
].possible_crtcs
;
855 rcdu
->dpad0_source
= ffs(dpad0_sources
) - 1;
857 drm_mode_config_reset(dev
);
859 drm_kms_helper_poll_init(dev
);