rcar_du_kms.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * rcar_du_kms.c -- R-Car Display Unit Mode Setting
  3. *
  4. * Copyright (C) 2013-2015 Renesas Electronics Corporation
  5. *
  6. * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <drm/drmP.h>
  14. #include <drm/drm_atomic.h>
  15. #include <drm/drm_atomic_helper.h>
  16. #include <drm/drm_crtc.h>
  17. #include <drm/drm_crtc_helper.h>
  18. #include <drm/drm_fb_cma_helper.h>
  19. #include <drm/drm_gem_cma_helper.h>
  20. #include <linux/of_graph.h>
  21. #include <linux/wait.h>
  22. #include "rcar_du_crtc.h"
  23. #include "rcar_du_drv.h"
  24. #include "rcar_du_encoder.h"
  25. #include "rcar_du_kms.h"
  26. #include "rcar_du_lvdsenc.h"
  27. #include "rcar_du_regs.h"
  28. #include "rcar_du_vsp.h"
  29. /* -----------------------------------------------------------------------------
  30. * Format helpers
  31. */
  32. static const struct rcar_du_format_info rcar_du_format_infos[] = {
  33. {
  34. .fourcc = DRM_FORMAT_RGB565,
  35. .bpp = 16,
  36. .planes = 1,
  37. .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP,
  38. .edf = PnDDCR4_EDF_NONE,
  39. }, {
  40. .fourcc = DRM_FORMAT_ARGB1555,
  41. .bpp = 16,
  42. .planes = 1,
  43. .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB,
  44. .edf = PnDDCR4_EDF_NONE,
  45. }, {
  46. .fourcc = DRM_FORMAT_XRGB1555,
  47. .bpp = 16,
  48. .planes = 1,
  49. .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB,
  50. .edf = PnDDCR4_EDF_NONE,
  51. }, {
  52. .fourcc = DRM_FORMAT_XRGB8888,
  53. .bpp = 32,
  54. .planes = 1,
  55. .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP,
  56. .edf = PnDDCR4_EDF_RGB888,
  57. }, {
  58. .fourcc = DRM_FORMAT_ARGB8888,
  59. .bpp = 32,
  60. .planes = 1,
  61. .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_16BPP,
  62. .edf = PnDDCR4_EDF_ARGB8888,
  63. }, {
  64. .fourcc = DRM_FORMAT_UYVY,
  65. .bpp = 16,
  66. .planes = 1,
  67. .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
  68. .edf = PnDDCR4_EDF_NONE,
  69. }, {
  70. .fourcc = DRM_FORMAT_YUYV,
  71. .bpp = 16,
  72. .planes = 1,
  73. .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
  74. .edf = PnDDCR4_EDF_NONE,
  75. }, {
  76. .fourcc = DRM_FORMAT_NV12,
  77. .bpp = 12,
  78. .planes = 2,
  79. .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
  80. .edf = PnDDCR4_EDF_NONE,
  81. }, {
  82. .fourcc = DRM_FORMAT_NV21,
  83. .bpp = 12,
  84. .planes = 2,
  85. .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
  86. .edf = PnDDCR4_EDF_NONE,
  87. }, {
  88. .fourcc = DRM_FORMAT_NV16,
  89. .bpp = 16,
  90. .planes = 2,
  91. .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
  92. .edf = PnDDCR4_EDF_NONE,
  93. },
  94. /* The following formats are not supported on Gen2 and thus have no
  95. * associated .pnmr or .edf settings.
  96. */
  97. {
  98. .fourcc = DRM_FORMAT_NV61,
  99. .bpp = 16,
  100. .planes = 2,
  101. }, {
  102. .fourcc = DRM_FORMAT_YUV420,
  103. .bpp = 12,
  104. .planes = 3,
  105. }, {
  106. .fourcc = DRM_FORMAT_YVU420,
  107. .bpp = 12,
  108. .planes = 3,
  109. }, {
  110. .fourcc = DRM_FORMAT_YUV422,
  111. .bpp = 16,
  112. .planes = 3,
  113. }, {
  114. .fourcc = DRM_FORMAT_YVU422,
  115. .bpp = 16,
  116. .planes = 3,
  117. }, {
  118. .fourcc = DRM_FORMAT_YUV444,
  119. .bpp = 24,
  120. .planes = 3,
  121. }, {
  122. .fourcc = DRM_FORMAT_YVU444,
  123. .bpp = 24,
  124. .planes = 3,
  125. },
  126. };
  127. const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc)
  128. {
  129. unsigned int i;
  130. for (i = 0; i < ARRAY_SIZE(rcar_du_format_infos); ++i) {
  131. if (rcar_du_format_infos[i].fourcc == fourcc)
  132. return &rcar_du_format_infos[i];
  133. }
  134. return NULL;
  135. }
  136. /* -----------------------------------------------------------------------------
  137. * Frame buffer
  138. */
  139. int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
  140. struct drm_mode_create_dumb *args)
  141. {
  142. struct rcar_du_device *rcdu = dev->dev_private;
  143. unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
  144. unsigned int align;
  145. /* The R8A7779 DU requires a 16 pixels pitch alignment as documented,
  146. * but the R8A7790 DU seems to require a 128 bytes pitch alignment.
  147. */
  148. if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
  149. align = 128;
  150. else
  151. align = 16 * args->bpp / 8;
  152. args->pitch = roundup(min_pitch, align);
  153. return drm_gem_cma_dumb_create_internal(file, dev, args);
  154. }
  155. static struct drm_framebuffer *
  156. rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
  157. const struct drm_mode_fb_cmd2 *mode_cmd)
  158. {
  159. struct rcar_du_device *rcdu = dev->dev_private;
  160. const struct rcar_du_format_info *format;
  161. unsigned int max_pitch;
  162. unsigned int align;
  163. unsigned int bpp;
  164. unsigned int i;
  165. format = rcar_du_format_info(mode_cmd->pixel_format);
  166. if (format == NULL) {
  167. dev_dbg(dev->dev, "unsupported pixel format %08x\n",
  168. mode_cmd->pixel_format);
  169. return ERR_PTR(-EINVAL);
  170. }
  171. /*
  172. * The pitch and alignment constraints are expressed in pixels on the
  173. * hardware side and in bytes in the DRM API.
  174. */
  175. bpp = format->planes == 1 ? format->bpp / 8 : 1;
  176. max_pitch = 4096 * bpp;
  177. if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
  178. align = 128;
  179. else
  180. align = 16 * bpp;
  181. if (mode_cmd->pitches[0] & (align - 1) ||
  182. mode_cmd->pitches[0] >= max_pitch) {
  183. dev_dbg(dev->dev, "invalid pitch value %u\n",
  184. mode_cmd->pitches[0]);
  185. return ERR_PTR(-EINVAL);
  186. }
  187. for (i = 1; i < format->planes; ++i) {
  188. if (mode_cmd->pitches[i] != mode_cmd->pitches[0]) {
  189. dev_dbg(dev->dev,
  190. "luma and chroma pitches do not match\n");
  191. return ERR_PTR(-EINVAL);
  192. }
  193. }
  194. return drm_fb_cma_create(dev, file_priv, mode_cmd);
  195. }
  196. static void rcar_du_output_poll_changed(struct drm_device *dev)
  197. {
  198. struct rcar_du_device *rcdu = dev->dev_private;
  199. drm_fbdev_cma_hotplug_event(rcdu->fbdev);
  200. }
  201. /* -----------------------------------------------------------------------------
  202. * Atomic Check and Update
  203. */
  204. static int rcar_du_atomic_check(struct drm_device *dev,
  205. struct drm_atomic_state *state)
  206. {
  207. struct rcar_du_device *rcdu = dev->dev_private;
  208. int ret;
  209. ret = drm_atomic_helper_check_modeset(dev, state);
  210. if (ret)
  211. return ret;
  212. ret = drm_atomic_normalize_zpos(dev, state);
  213. if (ret)
  214. return ret;
  215. ret = drm_atomic_helper_check_planes(dev, state);
  216. if (ret)
  217. return ret;
  218. if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
  219. return 0;
  220. return rcar_du_atomic_check_planes(dev, state);
  221. }
  222. struct rcar_du_commit {
  223. struct work_struct work;
  224. struct drm_device *dev;
  225. struct drm_atomic_state *state;
  226. u32 crtcs;
  227. };
  228. static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
  229. {
  230. struct drm_device *dev = commit->dev;
  231. struct rcar_du_device *rcdu = dev->dev_private;
  232. struct drm_atomic_state *old_state = commit->state;
  233. /* Apply the atomic update. */
  234. drm_atomic_helper_commit_modeset_disables(dev, old_state);
  235. drm_atomic_helper_commit_modeset_enables(dev, old_state);
  236. drm_atomic_helper_commit_planes(dev, old_state,
  237. DRM_PLANE_COMMIT_ACTIVE_ONLY);
  238. drm_atomic_helper_wait_for_vblanks(dev, old_state);
  239. drm_atomic_helper_cleanup_planes(dev, old_state);
  240. drm_atomic_state_put(old_state);
  241. /* Complete the commit, wake up any waiter. */
  242. spin_lock(&rcdu->commit.wait.lock);
  243. rcdu->commit.pending &= ~commit->crtcs;
  244. wake_up_all_locked(&rcdu->commit.wait);
  245. spin_unlock(&rcdu->commit.wait.lock);
  246. kfree(commit);
  247. }
  248. static void rcar_du_atomic_work(struct work_struct *work)
  249. {
  250. struct rcar_du_commit *commit =
  251. container_of(work, struct rcar_du_commit, work);
  252. rcar_du_atomic_complete(commit);
  253. }
  254. static int rcar_du_atomic_commit(struct drm_device *dev,
  255. struct drm_atomic_state *state,
  256. bool nonblock)
  257. {
  258. struct rcar_du_device *rcdu = dev->dev_private;
  259. struct rcar_du_commit *commit;
  260. struct drm_crtc *crtc;
  261. struct drm_crtc_state *crtc_state;
  262. unsigned int i;
  263. int ret;
  264. ret = drm_atomic_helper_prepare_planes(dev, state);
  265. if (ret)
  266. return ret;
  267. /* Allocate the commit object. */
  268. commit = kzalloc(sizeof(*commit), GFP_KERNEL);
  269. if (commit == NULL) {
  270. ret = -ENOMEM;
  271. goto error;
  272. }
  273. INIT_WORK(&commit->work, rcar_du_atomic_work);
  274. commit->dev = dev;
  275. commit->state = state;
  276. /* Wait until all affected CRTCs have completed previous commits and
  277. * mark them as pending.
  278. */
  279. for_each_crtc_in_state(state, crtc, crtc_state, i)
  280. commit->crtcs |= drm_crtc_mask(crtc);
  281. spin_lock(&rcdu->commit.wait.lock);
  282. ret = wait_event_interruptible_locked(rcdu->commit.wait,
  283. !(rcdu->commit.pending & commit->crtcs));
  284. if (ret == 0)
  285. rcdu->commit.pending |= commit->crtcs;
  286. spin_unlock(&rcdu->commit.wait.lock);
  287. if (ret) {
  288. kfree(commit);
  289. goto error;
  290. }
  291. /* Swap the state, this is the point of no return. */
  292. drm_atomic_helper_swap_state(state, true);
  293. drm_atomic_state_get(state);
  294. if (nonblock)
  295. schedule_work(&commit->work);
  296. else
  297. rcar_du_atomic_complete(commit);
  298. return 0;
  299. error:
  300. drm_atomic_helper_cleanup_planes(dev, state);
  301. return ret;
  302. }
  303. /* -----------------------------------------------------------------------------
  304. * Initialization
  305. */
  306. static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = {
  307. .fb_create = rcar_du_fb_create,
  308. .output_poll_changed = rcar_du_output_poll_changed,
  309. .atomic_check = rcar_du_atomic_check,
  310. .atomic_commit = rcar_du_atomic_commit,
  311. };
  312. static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu,
  313. enum rcar_du_output output,
  314. struct of_endpoint *ep)
  315. {
  316. static const struct {
  317. const char *compatible;
  318. enum rcar_du_encoder_type type;
  319. } encoders[] = {
  320. { "adi,adv7123", RCAR_DU_ENCODER_VGA },
  321. { "adi,adv7511w", RCAR_DU_ENCODER_HDMI },
  322. { "thine,thc63lvdm83d", RCAR_DU_ENCODER_LVDS },
  323. };
  324. enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE;
  325. struct device_node *connector = NULL;
  326. struct device_node *encoder = NULL;
  327. struct device_node *ep_node = NULL;
  328. struct device_node *entity_ep_node;
  329. struct device_node *entity;
  330. int ret;
  331. /*
  332. * Locate the connected entity and infer its type from the number of
  333. * endpoints.
  334. */
  335. entity = of_graph_get_remote_port_parent(ep->local_node);
  336. if (!entity) {
  337. dev_dbg(rcdu->dev, "unconnected endpoint %s, skipping\n",
  338. ep->local_node->full_name);
  339. return -ENODEV;
  340. }
  341. entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0);
  342. for_each_endpoint_of_node(entity, ep_node) {
  343. if (ep_node == entity_ep_node)
  344. continue;
  345. /*
  346. * We've found one endpoint other than the input, this must
  347. * be an encoder. Locate the connector.
  348. */
  349. encoder = entity;
  350. connector = of_graph_get_remote_port_parent(ep_node);
  351. of_node_put(ep_node);
  352. if (!connector) {
  353. dev_warn(rcdu->dev,
  354. "no connector for encoder %s, skipping\n",
  355. encoder->full_name);
  356. of_node_put(entity_ep_node);
  357. of_node_put(encoder);
  358. return -ENODEV;
  359. }
  360. break;
  361. }
  362. of_node_put(entity_ep_node);
  363. if (encoder) {
  364. /*
  365. * If an encoder has been found, get its type based on its
  366. * compatible string.
  367. */
  368. unsigned int i;
  369. for (i = 0; i < ARRAY_SIZE(encoders); ++i) {
  370. if (of_device_is_compatible(encoder,
  371. encoders[i].compatible)) {
  372. enc_type = encoders[i].type;
  373. break;
  374. }
  375. }
  376. if (i == ARRAY_SIZE(encoders)) {
  377. dev_warn(rcdu->dev,
  378. "unknown encoder type for %s, skipping\n",
  379. encoder->full_name);
  380. of_node_put(encoder);
  381. of_node_put(connector);
  382. return -EINVAL;
  383. }
  384. } else {
  385. /*
  386. * If no encoder has been found the entity must be the
  387. * connector.
  388. */
  389. connector = entity;
  390. }
  391. ret = rcar_du_encoder_init(rcdu, enc_type, output, encoder, connector);
  392. if (ret && ret != -EPROBE_DEFER)
  393. dev_warn(rcdu->dev,
  394. "failed to initialize encoder %s on output %u (%d), skipping\n",
  395. of_node_full_name(encoder), output, ret);
  396. of_node_put(encoder);
  397. of_node_put(connector);
  398. return ret;
  399. }
  400. static int rcar_du_encoders_init(struct rcar_du_device *rcdu)
  401. {
  402. struct device_node *np = rcdu->dev->of_node;
  403. struct device_node *ep_node;
  404. unsigned int num_encoders = 0;
  405. /*
  406. * Iterate over the endpoints and create one encoder for each output
  407. * pipeline.
  408. */
  409. for_each_endpoint_of_node(np, ep_node) {
  410. enum rcar_du_output output;
  411. struct of_endpoint ep;
  412. unsigned int i;
  413. int ret;
  414. ret = of_graph_parse_endpoint(ep_node, &ep);
  415. if (ret < 0) {
  416. of_node_put(ep_node);
  417. return ret;
  418. }
  419. /* Find the output route corresponding to the port number. */
  420. for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) {
  421. if (rcdu->info->routes[i].possible_crtcs &&
  422. rcdu->info->routes[i].port == ep.port) {
  423. output = i;
  424. break;
  425. }
  426. }
  427. if (i == RCAR_DU_OUTPUT_MAX) {
  428. dev_warn(rcdu->dev,
  429. "port %u references unexisting output, skipping\n",
  430. ep.port);
  431. continue;
  432. }
  433. /* Process the output pipeline. */
  434. ret = rcar_du_encoders_init_one(rcdu, output, &ep);
  435. if (ret < 0) {
  436. if (ret == -EPROBE_DEFER) {
  437. of_node_put(ep_node);
  438. return ret;
  439. }
  440. continue;
  441. }
  442. num_encoders++;
  443. }
  444. return num_encoders;
  445. }
  446. static int rcar_du_properties_init(struct rcar_du_device *rcdu)
  447. {
  448. rcdu->props.alpha =
  449. drm_property_create_range(rcdu->ddev, 0, "alpha", 0, 255);
  450. if (rcdu->props.alpha == NULL)
  451. return -ENOMEM;
  452. /* The color key is expressed as an RGB888 triplet stored in a 32-bit
  453. * integer in XRGB8888 format. Bit 24 is used as a flag to disable (0)
  454. * or enable source color keying (1).
  455. */
  456. rcdu->props.colorkey =
  457. drm_property_create_range(rcdu->ddev, 0, "colorkey",
  458. 0, 0x01ffffff);
  459. if (rcdu->props.colorkey == NULL)
  460. return -ENOMEM;
  461. return 0;
  462. }
  463. int rcar_du_modeset_init(struct rcar_du_device *rcdu)
  464. {
  465. static const unsigned int mmio_offsets[] = {
  466. DU0_REG_OFFSET, DU2_REG_OFFSET
  467. };
  468. struct drm_device *dev = rcdu->ddev;
  469. struct drm_encoder *encoder;
  470. struct drm_fbdev_cma *fbdev;
  471. unsigned int num_encoders;
  472. unsigned int num_groups;
  473. unsigned int i;
  474. int ret;
  475. drm_mode_config_init(dev);
  476. dev->mode_config.min_width = 0;
  477. dev->mode_config.min_height = 0;
  478. dev->mode_config.max_width = 4095;
  479. dev->mode_config.max_height = 2047;
  480. dev->mode_config.funcs = &rcar_du_mode_config_funcs;
  481. rcdu->num_crtcs = rcdu->info->num_crtcs;
  482. ret = rcar_du_properties_init(rcdu);
  483. if (ret < 0)
  484. return ret;
  485. /* Initialize vertical blanking interrupts handling. Start with vblank
  486. * disabled for all CRTCs.
  487. */
  488. ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
  489. if (ret < 0)
  490. return ret;
  491. /* Initialize the groups. */
  492. num_groups = DIV_ROUND_UP(rcdu->num_crtcs, 2);
  493. for (i = 0; i < num_groups; ++i) {
  494. struct rcar_du_group *rgrp = &rcdu->groups[i];
  495. mutex_init(&rgrp->lock);
  496. rgrp->dev = rcdu;
  497. rgrp->mmio_offset = mmio_offsets[i];
  498. rgrp->index = i;
  499. rgrp->num_crtcs = min(rcdu->num_crtcs - 2 * i, 2U);
  500. /* If we have more than one CRTCs in this group pre-associate
  501. * the low-order planes with CRTC 0 and the high-order planes
  502. * with CRTC 1 to minimize flicker occurring when the
  503. * association is changed.
  504. */
  505. rgrp->dptsr_planes = rgrp->num_crtcs > 1
  506. ? (rcdu->info->gen >= 3 ? 0x04 : 0xf0)
  507. : 0;
  508. if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
  509. ret = rcar_du_planes_init(rgrp);
  510. if (ret < 0)
  511. return ret;
  512. }
  513. }
  514. /* Initialize the compositors. */
  515. if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
  516. for (i = 0; i < rcdu->num_crtcs; ++i) {
  517. struct rcar_du_vsp *vsp = &rcdu->vsps[i];
  518. vsp->index = i;
  519. vsp->dev = rcdu;
  520. rcdu->crtcs[i].vsp = vsp;
  521. ret = rcar_du_vsp_init(vsp);
  522. if (ret < 0)
  523. return ret;
  524. }
  525. }
  526. /* Create the CRTCs. */
  527. for (i = 0; i < rcdu->num_crtcs; ++i) {
  528. struct rcar_du_group *rgrp = &rcdu->groups[i / 2];
  529. ret = rcar_du_crtc_create(rgrp, i);
  530. if (ret < 0)
  531. return ret;
  532. }
  533. /* Initialize the encoders. */
  534. ret = rcar_du_lvdsenc_init(rcdu);
  535. if (ret < 0)
  536. return ret;
  537. ret = rcar_du_encoders_init(rcdu);
  538. if (ret < 0)
  539. return ret;
  540. if (ret == 0) {
  541. dev_err(rcdu->dev, "error: no encoder could be initialized\n");
  542. return -EINVAL;
  543. }
  544. num_encoders = ret;
  545. /* Set the possible CRTCs and possible clones. There's always at least
  546. * one way for all encoders to clone each other, set all bits in the
  547. * possible clones field.
  548. */
  549. list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
  550. struct rcar_du_encoder *renc = to_rcar_encoder(encoder);
  551. const struct rcar_du_output_routing *route =
  552. &rcdu->info->routes[renc->output];
  553. encoder->possible_crtcs = route->possible_crtcs;
  554. encoder->possible_clones = (1 << num_encoders) - 1;
  555. }
  556. drm_mode_config_reset(dev);
  557. drm_kms_helper_poll_init(dev);
  558. if (dev->mode_config.num_connector) {
  559. fbdev = drm_fbdev_cma_init(dev, 32, dev->mode_config.num_crtc,
  560. dev->mode_config.num_connector);
  561. if (IS_ERR(fbdev))
  562. return PTR_ERR(fbdev);
  563. rcdu->fbdev = fbdev;
  564. } else {
  565. dev_info(rcdu->dev,
  566. "no connector found, disabling fbdev emulation\n");
  567. }
  568. return 0;
  569. }