intel_dsi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. * Copyright © 2013 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Author: Jani Nikula <jani.nikula@intel.com>
  24. */
  25. #include <drm/drmP.h>
  26. #include <drm/drm_crtc.h>
  27. #include <drm/drm_edid.h>
  28. #include <drm/i915_drm.h>
  29. #include <linux/slab.h>
  30. #include "i915_drv.h"
  31. #include "intel_drv.h"
  32. #include "intel_dsi.h"
  33. #include "intel_dsi_cmd.h"
  34. /* the sub-encoders aka panel drivers */
  35. static const struct intel_dsi_device intel_dsi_devices[] = {
  36. };
  37. static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector)
  38. {
  39. return container_of(intel_attached_encoder(connector),
  40. struct intel_dsi, base);
  41. }
  42. static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
  43. {
  44. return intel_dsi->dev.type == INTEL_DSI_VIDEO_MODE;
  45. }
  46. static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
  47. {
  48. return intel_dsi->dev.type == INTEL_DSI_COMMAND_MODE;
  49. }
  50. static void intel_dsi_hot_plug(struct intel_encoder *encoder)
  51. {
  52. DRM_DEBUG_KMS("\n");
  53. }
  54. static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  55. struct intel_crtc_config *config)
  56. {
  57. struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
  58. base);
  59. struct intel_connector *intel_connector = intel_dsi->attached_connector;
  60. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  61. struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
  62. struct drm_display_mode *mode = &config->requested_mode;
  63. DRM_DEBUG_KMS("\n");
  64. if (fixed_mode)
  65. intel_fixed_panel_mode(fixed_mode, adjusted_mode);
  66. if (intel_dsi->dev.dev_ops->mode_fixup)
  67. return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
  68. mode, adjusted_mode);
  69. return true;
  70. }
  71. static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
  72. {
  73. DRM_DEBUG_KMS("\n");
  74. }
  75. static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  76. {
  77. DRM_DEBUG_KMS("\n");
  78. }
  79. static void intel_dsi_enable(struct intel_encoder *encoder)
  80. {
  81. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  82. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  83. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  84. int pipe = intel_crtc->pipe;
  85. u32 temp;
  86. DRM_DEBUG_KMS("\n");
  87. temp = I915_READ(MIPI_DEVICE_READY(pipe));
  88. if ((temp & DEVICE_READY) == 0) {
  89. temp &= ~ULPS_STATE_MASK;
  90. I915_WRITE(MIPI_DEVICE_READY(pipe), temp | DEVICE_READY);
  91. } else if (temp & ULPS_STATE_MASK) {
  92. temp &= ~ULPS_STATE_MASK;
  93. I915_WRITE(MIPI_DEVICE_READY(pipe), temp | ULPS_STATE_EXIT);
  94. /*
  95. * We need to ensure that there is a minimum of 1 ms time
  96. * available before clearing the UPLS exit state.
  97. */
  98. msleep(2);
  99. I915_WRITE(MIPI_DEVICE_READY(pipe), temp);
  100. }
  101. if (is_cmd_mode(intel_dsi))
  102. I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(pipe), 8 * 4);
  103. if (is_vid_mode(intel_dsi)) {
  104. msleep(20); /* XXX */
  105. dpi_send_cmd(intel_dsi, TURN_ON);
  106. msleep(100);
  107. /* assert ip_tg_enable signal */
  108. temp = I915_READ(MIPI_PORT_CTRL(pipe));
  109. I915_WRITE(MIPI_PORT_CTRL(pipe), temp | DPI_ENABLE);
  110. POSTING_READ(MIPI_PORT_CTRL(pipe));
  111. }
  112. intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
  113. }
  114. static void intel_dsi_disable(struct intel_encoder *encoder)
  115. {
  116. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  117. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  118. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  119. int pipe = intel_crtc->pipe;
  120. u32 temp;
  121. DRM_DEBUG_KMS("\n");
  122. intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
  123. if (is_vid_mode(intel_dsi)) {
  124. dpi_send_cmd(intel_dsi, SHUTDOWN);
  125. msleep(10);
  126. /* de-assert ip_tg_enable signal */
  127. temp = I915_READ(MIPI_PORT_CTRL(pipe));
  128. I915_WRITE(MIPI_PORT_CTRL(pipe), temp & ~DPI_ENABLE);
  129. POSTING_READ(MIPI_PORT_CTRL(pipe));
  130. msleep(2);
  131. }
  132. temp = I915_READ(MIPI_DEVICE_READY(pipe));
  133. if (temp & DEVICE_READY) {
  134. temp &= ~DEVICE_READY;
  135. temp &= ~ULPS_STATE_MASK;
  136. I915_WRITE(MIPI_DEVICE_READY(pipe), temp);
  137. }
  138. }
  139. static void intel_dsi_post_disable(struct intel_encoder *encoder)
  140. {
  141. DRM_DEBUG_KMS("\n");
  142. }
  143. static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
  144. enum pipe *pipe)
  145. {
  146. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  147. u32 port, func;
  148. enum pipe p;
  149. DRM_DEBUG_KMS("\n");
  150. /* XXX: this only works for one DSI output */
  151. for (p = PIPE_A; p <= PIPE_B; p++) {
  152. port = I915_READ(MIPI_PORT_CTRL(p));
  153. func = I915_READ(MIPI_DSI_FUNC_PRG(p));
  154. if ((port & DPI_ENABLE) || (func & CMD_MODE_DATA_WIDTH_MASK)) {
  155. if (I915_READ(MIPI_DEVICE_READY(p)) & DEVICE_READY) {
  156. *pipe = p;
  157. return true;
  158. }
  159. }
  160. }
  161. return false;
  162. }
  163. static void intel_dsi_get_config(struct intel_encoder *encoder,
  164. struct intel_crtc_config *pipe_config)
  165. {
  166. DRM_DEBUG_KMS("\n");
  167. /* XXX: read flags, set to adjusted_mode */
  168. }
  169. static int intel_dsi_mode_valid(struct drm_connector *connector,
  170. struct drm_display_mode *mode)
  171. {
  172. struct intel_connector *intel_connector = to_intel_connector(connector);
  173. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  174. struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
  175. DRM_DEBUG_KMS("\n");
  176. if (mode->flags & DRM_MODE_FLAG_DBLSCAN) {
  177. DRM_DEBUG_KMS("MODE_NO_DBLESCAN\n");
  178. return MODE_NO_DBLESCAN;
  179. }
  180. if (fixed_mode) {
  181. if (mode->hdisplay > fixed_mode->hdisplay)
  182. return MODE_PANEL;
  183. if (mode->vdisplay > fixed_mode->vdisplay)
  184. return MODE_PANEL;
  185. }
  186. return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode);
  187. }
  188. /* return txclkesc cycles in terms of divider and duration in us */
  189. static u16 txclkesc(u32 divider, unsigned int us)
  190. {
  191. switch (divider) {
  192. case ESCAPE_CLOCK_DIVIDER_1:
  193. default:
  194. return 20 * us;
  195. case ESCAPE_CLOCK_DIVIDER_2:
  196. return 10 * us;
  197. case ESCAPE_CLOCK_DIVIDER_4:
  198. return 5 * us;
  199. }
  200. }
  201. /* return pixels in terms of txbyteclkhs */
  202. static u16 txbyteclkhs(u16 pixels, int bpp, int lane_count)
  203. {
  204. return DIV_ROUND_UP(DIV_ROUND_UP(pixels * bpp, 8), lane_count);
  205. }
  206. static void set_dsi_timings(struct drm_encoder *encoder,
  207. const struct drm_display_mode *mode)
  208. {
  209. struct drm_device *dev = encoder->dev;
  210. struct drm_i915_private *dev_priv = dev->dev_private;
  211. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  212. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  213. int pipe = intel_crtc->pipe;
  214. unsigned int bpp = intel_crtc->config.pipe_bpp;
  215. unsigned int lane_count = intel_dsi->lane_count;
  216. u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp;
  217. hactive = mode->hdisplay;
  218. hfp = mode->hsync_start - mode->hdisplay;
  219. hsync = mode->hsync_end - mode->hsync_start;
  220. hbp = mode->htotal - mode->hsync_end;
  221. vfp = mode->vsync_start - mode->vdisplay;
  222. vsync = mode->vsync_end - mode->vsync_start;
  223. vbp = mode->vtotal - mode->vsync_end;
  224. /* horizontal values are in terms of high speed byte clock */
  225. hactive = txbyteclkhs(hactive, bpp, lane_count);
  226. hfp = txbyteclkhs(hfp, bpp, lane_count);
  227. hsync = txbyteclkhs(hsync, bpp, lane_count);
  228. hbp = txbyteclkhs(hbp, bpp, lane_count);
  229. I915_WRITE(MIPI_HACTIVE_AREA_COUNT(pipe), hactive);
  230. I915_WRITE(MIPI_HFP_COUNT(pipe), hfp);
  231. /* meaningful for video mode non-burst sync pulse mode only, can be zero
  232. * for non-burst sync events and burst modes */
  233. I915_WRITE(MIPI_HSYNC_PADDING_COUNT(pipe), hsync);
  234. I915_WRITE(MIPI_HBP_COUNT(pipe), hbp);
  235. /* vertical values are in terms of lines */
  236. I915_WRITE(MIPI_VFP_COUNT(pipe), vfp);
  237. I915_WRITE(MIPI_VSYNC_PADDING_COUNT(pipe), vsync);
  238. I915_WRITE(MIPI_VBP_COUNT(pipe), vbp);
  239. }
  240. static void intel_dsi_mode_set(struct intel_encoder *intel_encoder)
  241. {
  242. struct drm_encoder *encoder = &intel_encoder->base;
  243. struct drm_device *dev = encoder->dev;
  244. struct drm_i915_private *dev_priv = dev->dev_private;
  245. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  246. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  247. struct drm_display_mode *adjusted_mode =
  248. &intel_crtc->config.adjusted_mode;
  249. int pipe = intel_crtc->pipe;
  250. unsigned int bpp = intel_crtc->config.pipe_bpp;
  251. u32 val, tmp;
  252. DRM_DEBUG_KMS("pipe %d\n", pipe);
  253. /* escape clock divider, 20MHz, shared for A and C. device ready must be
  254. * off when doing this! txclkesc? */
  255. tmp = I915_READ(MIPI_CTRL(0));
  256. tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  257. I915_WRITE(MIPI_CTRL(0), tmp | ESCAPE_CLOCK_DIVIDER_1);
  258. /* read request priority is per pipe */
  259. tmp = I915_READ(MIPI_CTRL(pipe));
  260. tmp &= ~READ_REQUEST_PRIORITY_MASK;
  261. I915_WRITE(MIPI_CTRL(pipe), tmp | READ_REQUEST_PRIORITY_HIGH);
  262. /* XXX: why here, why like this? handling in irq handler?! */
  263. I915_WRITE(MIPI_INTR_STAT(pipe), 0xffffffff);
  264. I915_WRITE(MIPI_INTR_EN(pipe), 0xffffffff);
  265. I915_WRITE(MIPI_DPHY_PARAM(pipe),
  266. 0x3c << EXIT_ZERO_COUNT_SHIFT |
  267. 0x1f << TRAIL_COUNT_SHIFT |
  268. 0xc5 << CLK_ZERO_COUNT_SHIFT |
  269. 0x1f << PREPARE_COUNT_SHIFT);
  270. I915_WRITE(MIPI_DPI_RESOLUTION(pipe),
  271. adjusted_mode->vdisplay << VERTICAL_ADDRESS_SHIFT |
  272. adjusted_mode->hdisplay << HORIZONTAL_ADDRESS_SHIFT);
  273. set_dsi_timings(encoder, adjusted_mode);
  274. val = intel_dsi->lane_count << DATA_LANES_PRG_REG_SHIFT;
  275. if (is_cmd_mode(intel_dsi)) {
  276. val |= intel_dsi->channel << CMD_MODE_CHANNEL_NUMBER_SHIFT;
  277. val |= CMD_MODE_DATA_WIDTH_8_BIT; /* XXX */
  278. } else {
  279. val |= intel_dsi->channel << VID_MODE_CHANNEL_NUMBER_SHIFT;
  280. /* XXX: cross-check bpp vs. pixel format? */
  281. val |= intel_dsi->pixel_format;
  282. }
  283. I915_WRITE(MIPI_DSI_FUNC_PRG(pipe), val);
  284. /* timeouts for recovery. one frame IIUC. if counter expires, EOT and
  285. * stop state. */
  286. /*
  287. * In burst mode, value greater than one DPI line Time in byte clock
  288. * (txbyteclkhs) To timeout this timer 1+ of the above said value is
  289. * recommended.
  290. *
  291. * In non-burst mode, Value greater than one DPI frame time in byte
  292. * clock(txbyteclkhs) To timeout this timer 1+ of the above said value
  293. * is recommended.
  294. *
  295. * In DBI only mode, value greater than one DBI frame time in byte
  296. * clock(txbyteclkhs) To timeout this timer 1+ of the above said value
  297. * is recommended.
  298. */
  299. if (is_vid_mode(intel_dsi) &&
  300. intel_dsi->video_mode_format == VIDEO_MODE_BURST) {
  301. I915_WRITE(MIPI_HS_TX_TIMEOUT(pipe),
  302. txbyteclkhs(adjusted_mode->htotal, bpp,
  303. intel_dsi->lane_count) + 1);
  304. } else {
  305. I915_WRITE(MIPI_HS_TX_TIMEOUT(pipe),
  306. txbyteclkhs(adjusted_mode->vtotal *
  307. adjusted_mode->htotal,
  308. bpp, intel_dsi->lane_count) + 1);
  309. }
  310. I915_WRITE(MIPI_LP_RX_TIMEOUT(pipe), 8309); /* max */
  311. I915_WRITE(MIPI_TURN_AROUND_TIMEOUT(pipe), 0x14); /* max */
  312. I915_WRITE(MIPI_DEVICE_RESET_TIMER(pipe), 0xffff); /* max */
  313. /* dphy stuff */
  314. /* in terms of low power clock */
  315. I915_WRITE(MIPI_INIT_COUNT(pipe), txclkesc(ESCAPE_CLOCK_DIVIDER_1, 100));
  316. /* recovery disables */
  317. I915_WRITE(MIPI_EOT_DISABLE(pipe), intel_dsi->eot_disable);
  318. /* in terms of txbyteclkhs. actual high to low switch +
  319. * MIPI_STOP_STATE_STALL * MIPI_LP_BYTECLK.
  320. *
  321. * XXX: write MIPI_STOP_STATE_STALL?
  322. */
  323. I915_WRITE(MIPI_HIGH_LOW_SWITCH_COUNT(pipe), 0x46);
  324. /* XXX: low power clock equivalence in terms of byte clock. the number
  325. * of byte clocks occupied in one low power clock. based on txbyteclkhs
  326. * and txclkesc. txclkesc time / txbyteclk time * (105 +
  327. * MIPI_STOP_STATE_STALL) / 105.???
  328. */
  329. I915_WRITE(MIPI_LP_BYTECLK(pipe), 4);
  330. /* the bw essential for transmitting 16 long packets containing 252
  331. * bytes meant for dcs write memory command is programmed in this
  332. * register in terms of byte clocks. based on dsi transfer rate and the
  333. * number of lanes configured the time taken to transmit 16 long packets
  334. * in a dsi stream varies. */
  335. I915_WRITE(MIPI_DBI_BW_CTRL(pipe), 0x820);
  336. I915_WRITE(MIPI_CLK_LANE_SWITCH_TIME_CNT(pipe),
  337. 0xa << LP_HS_SSW_CNT_SHIFT |
  338. 0x14 << HS_LP_PWR_SW_CNT_SHIFT);
  339. if (is_vid_mode(intel_dsi))
  340. I915_WRITE(MIPI_VIDEO_MODE_FORMAT(pipe),
  341. intel_dsi->video_mode_format);
  342. }
  343. static enum drm_connector_status
  344. intel_dsi_detect(struct drm_connector *connector, bool force)
  345. {
  346. struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
  347. DRM_DEBUG_KMS("\n");
  348. return intel_dsi->dev.dev_ops->detect(&intel_dsi->dev);
  349. }
  350. static int intel_dsi_get_modes(struct drm_connector *connector)
  351. {
  352. struct intel_connector *intel_connector = to_intel_connector(connector);
  353. struct drm_display_mode *mode;
  354. DRM_DEBUG_KMS("\n");
  355. if (!intel_connector->panel.fixed_mode) {
  356. DRM_DEBUG_KMS("no fixed mode\n");
  357. return 0;
  358. }
  359. mode = drm_mode_duplicate(connector->dev,
  360. intel_connector->panel.fixed_mode);
  361. if (!mode) {
  362. DRM_DEBUG_KMS("drm_mode_duplicate failed\n");
  363. return 0;
  364. }
  365. drm_mode_probed_add(connector, mode);
  366. return 1;
  367. }
  368. static void intel_dsi_destroy(struct drm_connector *connector)
  369. {
  370. struct intel_connector *intel_connector = to_intel_connector(connector);
  371. DRM_DEBUG_KMS("\n");
  372. intel_panel_fini(&intel_connector->panel);
  373. drm_sysfs_connector_remove(connector);
  374. drm_connector_cleanup(connector);
  375. kfree(connector);
  376. }
  377. static const struct drm_encoder_funcs intel_dsi_funcs = {
  378. .destroy = intel_encoder_destroy,
  379. };
  380. static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
  381. .get_modes = intel_dsi_get_modes,
  382. .mode_valid = intel_dsi_mode_valid,
  383. .best_encoder = intel_best_encoder,
  384. };
  385. static const struct drm_connector_funcs intel_dsi_connector_funcs = {
  386. .dpms = intel_connector_dpms,
  387. .detect = intel_dsi_detect,
  388. .destroy = intel_dsi_destroy,
  389. .fill_modes = drm_helper_probe_single_connector_modes,
  390. };
  391. bool intel_dsi_init(struct drm_device *dev)
  392. {
  393. struct intel_dsi *intel_dsi;
  394. struct intel_encoder *intel_encoder;
  395. struct drm_encoder *encoder;
  396. struct intel_connector *intel_connector;
  397. struct drm_connector *connector;
  398. struct drm_display_mode *fixed_mode = NULL;
  399. const struct intel_dsi_device *dsi;
  400. unsigned int i;
  401. DRM_DEBUG_KMS("\n");
  402. intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
  403. if (!intel_dsi)
  404. return false;
  405. intel_connector = kzalloc(sizeof(*intel_connector), GFP_KERNEL);
  406. if (!intel_connector) {
  407. kfree(intel_dsi);
  408. return false;
  409. }
  410. intel_encoder = &intel_dsi->base;
  411. encoder = &intel_encoder->base;
  412. intel_dsi->attached_connector = intel_connector;
  413. connector = &intel_connector->base;
  414. drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
  415. /* XXX: very likely not all of these are needed */
  416. intel_encoder->hot_plug = intel_dsi_hot_plug;
  417. intel_encoder->compute_config = intel_dsi_compute_config;
  418. intel_encoder->pre_pll_enable = intel_dsi_pre_pll_enable;
  419. intel_encoder->pre_enable = intel_dsi_pre_enable;
  420. intel_encoder->enable = intel_dsi_enable;
  421. intel_encoder->mode_set = intel_dsi_mode_set;
  422. intel_encoder->disable = intel_dsi_disable;
  423. intel_encoder->post_disable = intel_dsi_post_disable;
  424. intel_encoder->get_hw_state = intel_dsi_get_hw_state;
  425. intel_encoder->get_config = intel_dsi_get_config;
  426. intel_connector->get_hw_state = intel_connector_get_hw_state;
  427. for (i = 0; i < ARRAY_SIZE(intel_dsi_devices); i++) {
  428. dsi = &intel_dsi_devices[i];
  429. intel_dsi->dev = *dsi;
  430. if (dsi->dev_ops->init(&intel_dsi->dev))
  431. break;
  432. }
  433. if (i == ARRAY_SIZE(intel_dsi_devices)) {
  434. DRM_DEBUG_KMS("no device found\n");
  435. goto err;
  436. }
  437. intel_encoder->type = INTEL_OUTPUT_DSI;
  438. intel_encoder->crtc_mask = (1 << 0); /* XXX */
  439. intel_encoder->cloneable = false;
  440. drm_connector_init(dev, connector, &intel_dsi_connector_funcs,
  441. DRM_MODE_CONNECTOR_DSI);
  442. drm_connector_helper_add(connector, &intel_dsi_connector_helper_funcs);
  443. connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/
  444. connector->interlace_allowed = false;
  445. connector->doublescan_allowed = false;
  446. intel_connector_attach_encoder(intel_connector, intel_encoder);
  447. drm_sysfs_connector_add(connector);
  448. fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev);
  449. if (!fixed_mode) {
  450. DRM_DEBUG_KMS("no fixed mode\n");
  451. goto err;
  452. }
  453. fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  454. intel_panel_init(&intel_connector->panel, fixed_mode);
  455. return true;
  456. err:
  457. drm_encoder_cleanup(&intel_encoder->base);
  458. kfree(intel_dsi);
  459. kfree(intel_connector);
  460. return false;
  461. }