mdfld_dsi_output.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. * Copyright © 2010 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. * Authors:
  24. * jim liu <jim.liu@intel.com>
  25. * Jackie Li<yaodong.li@intel.com>
  26. */
  27. #include <linux/module.h>
  28. #include "mdfld_dsi_output.h"
  29. #include "mdfld_dsi_dpi.h"
  30. #include "mdfld_output.h"
  31. #include "mdfld_dsi_pkg_sender.h"
  32. #include "tc35876x-dsi-lvds.h"
  33. #include <linux/pm_runtime.h>
  34. #include <asm/intel_scu_ipc.h>
  35. /* get the LABC from command line. */
  36. static int LABC_control = 1;
  37. #ifdef MODULE
  38. module_param(LABC_control, int, 0644);
  39. #else
  40. static int __init parse_LABC_control(char *arg)
  41. {
  42. /* LABC control can be passed in as a cmdline parameter */
  43. /* to enable this feature add LABC=1 to cmdline */
  44. /* to disable this feature add LABC=0 to cmdline */
  45. if (!arg)
  46. return -EINVAL;
  47. if (!strcasecmp(arg, "0"))
  48. LABC_control = 0;
  49. else if (!strcasecmp(arg, "1"))
  50. LABC_control = 1;
  51. return 0;
  52. }
  53. early_param("LABC", parse_LABC_control);
  54. #endif
  55. /**
  56. * Check and see if the generic control or data buffer is empty and ready.
  57. */
  58. void mdfld_dsi_gen_fifo_ready(struct drm_device *dev, u32 gen_fifo_stat_reg,
  59. u32 fifo_stat)
  60. {
  61. u32 GEN_BF_time_out_count;
  62. /* Check MIPI Adatper command registers */
  63. for (GEN_BF_time_out_count = 0;
  64. GEN_BF_time_out_count < GEN_FB_TIME_OUT;
  65. GEN_BF_time_out_count++) {
  66. if ((REG_READ(gen_fifo_stat_reg) & fifo_stat) == fifo_stat)
  67. break;
  68. udelay(100);
  69. }
  70. if (GEN_BF_time_out_count == GEN_FB_TIME_OUT)
  71. DRM_ERROR("mdfld_dsi_gen_fifo_ready, Timeout. gen_fifo_stat_reg = 0x%x.\n",
  72. gen_fifo_stat_reg);
  73. }
  74. /**
  75. * Manage the DSI MIPI keyboard and display brightness.
  76. * FIXME: this is exported to OSPM code. should work out an specific
  77. * display interface to OSPM.
  78. */
  79. void mdfld_dsi_brightness_init(struct mdfld_dsi_config *dsi_config, int pipe)
  80. {
  81. struct mdfld_dsi_pkg_sender *sender =
  82. mdfld_dsi_get_pkg_sender(dsi_config);
  83. struct drm_device *dev = sender->dev;
  84. struct drm_psb_private *dev_priv = dev->dev_private;
  85. u32 gen_ctrl_val;
  86. if (!sender) {
  87. DRM_ERROR("No sender found\n");
  88. return;
  89. }
  90. /* Set default display backlight value to 85% (0xd8)*/
  91. mdfld_dsi_send_mcs_short(sender, write_display_brightness, 0xd8, 1,
  92. true);
  93. /* Set minimum brightness setting of CABC function to 20% (0x33)*/
  94. mdfld_dsi_send_mcs_short(sender, write_cabc_min_bright, 0x33, 1, true);
  95. /* Enable backlight or/and LABC */
  96. gen_ctrl_val = BRIGHT_CNTL_BLOCK_ON | DISPLAY_DIMMING_ON |
  97. BACKLIGHT_ON;
  98. if (LABC_control == 1)
  99. gen_ctrl_val |= DISPLAY_DIMMING_ON | DISPLAY_BRIGHTNESS_AUTO
  100. | GAMMA_AUTO;
  101. if (LABC_control == 1)
  102. gen_ctrl_val |= AMBIENT_LIGHT_SENSE_ON;
  103. dev_priv->mipi_ctrl_display = gen_ctrl_val;
  104. mdfld_dsi_send_mcs_short(sender, write_ctrl_display, (u8)gen_ctrl_val,
  105. 1, true);
  106. mdfld_dsi_send_mcs_short(sender, write_ctrl_cabc, UI_IMAGE, 1, true);
  107. }
  108. void mdfld_dsi_brightness_control(struct drm_device *dev, int pipe, int level)
  109. {
  110. struct mdfld_dsi_pkg_sender *sender;
  111. struct drm_psb_private *dev_priv;
  112. struct mdfld_dsi_config *dsi_config;
  113. u32 gen_ctrl_val = 0;
  114. int p_type = TMD_VID;
  115. if (!dev || (pipe != 0 && pipe != 2)) {
  116. DRM_ERROR("Invalid parameter\n");
  117. return;
  118. }
  119. p_type = mdfld_get_panel_type(dev, 0);
  120. dev_priv = dev->dev_private;
  121. if (pipe)
  122. dsi_config = dev_priv->dsi_configs[1];
  123. else
  124. dsi_config = dev_priv->dsi_configs[0];
  125. sender = mdfld_dsi_get_pkg_sender(dsi_config);
  126. if (!sender) {
  127. DRM_ERROR("No sender found\n");
  128. return;
  129. }
  130. gen_ctrl_val = (level * 0xff / MDFLD_DSI_BRIGHTNESS_MAX_LEVEL) & 0xff;
  131. dev_dbg(sender->dev->dev, "pipe = %d, gen_ctrl_val = %d.\n",
  132. pipe, gen_ctrl_val);
  133. if (p_type == TMD_VID) {
  134. /* Set display backlight value */
  135. mdfld_dsi_send_mcs_short(sender, tmd_write_display_brightness,
  136. (u8)gen_ctrl_val, 1, true);
  137. } else {
  138. /* Set display backlight value */
  139. mdfld_dsi_send_mcs_short(sender, write_display_brightness,
  140. (u8)gen_ctrl_val, 1, true);
  141. /* Enable backlight control */
  142. if (level == 0)
  143. gen_ctrl_val = 0;
  144. else
  145. gen_ctrl_val = dev_priv->mipi_ctrl_display;
  146. mdfld_dsi_send_mcs_short(sender, write_ctrl_display,
  147. (u8)gen_ctrl_val, 1, true);
  148. }
  149. }
  150. static int mdfld_dsi_get_panel_status(struct mdfld_dsi_config *dsi_config,
  151. u8 dcs, u32 *data, bool hs)
  152. {
  153. struct mdfld_dsi_pkg_sender *sender
  154. = mdfld_dsi_get_pkg_sender(dsi_config);
  155. if (!sender || !data) {
  156. DRM_ERROR("Invalid parameter\n");
  157. return -EINVAL;
  158. }
  159. return mdfld_dsi_read_mcs(sender, dcs, data, 1, hs);
  160. }
  161. int mdfld_dsi_get_power_mode(struct mdfld_dsi_config *dsi_config, u32 *mode,
  162. bool hs)
  163. {
  164. if (!dsi_config || !mode) {
  165. DRM_ERROR("Invalid parameter\n");
  166. return -EINVAL;
  167. }
  168. return mdfld_dsi_get_panel_status(dsi_config, 0x0a, mode, hs);
  169. }
  170. int mdfld_dsi_get_diagnostic_result(struct mdfld_dsi_config *dsi_config,
  171. u32 *result, bool hs)
  172. {
  173. if (!dsi_config || !result) {
  174. DRM_ERROR("Invalid parameter\n");
  175. return -EINVAL;
  176. }
  177. return mdfld_dsi_get_panel_status(dsi_config, 0x0f, result, hs);
  178. }
  179. /*
  180. * NOTE: this function was used by OSPM.
  181. * TODO: will be removed later, should work out display interfaces for OSPM
  182. */
  183. void mdfld_dsi_controller_init(struct mdfld_dsi_config *dsi_config, int pipe)
  184. {
  185. if (!dsi_config || ((pipe != 0) && (pipe != 2))) {
  186. DRM_ERROR("Invalid parameters\n");
  187. return;
  188. }
  189. mdfld_dsi_dpi_controller_init(dsi_config, pipe);
  190. }
  191. static void mdfld_dsi_connector_save(struct drm_connector *connector)
  192. {
  193. }
  194. static void mdfld_dsi_connector_restore(struct drm_connector *connector)
  195. {
  196. }
  197. /* FIXME: start using the force parameter */
  198. static enum drm_connector_status
  199. mdfld_dsi_connector_detect(struct drm_connector *connector, bool force)
  200. {
  201. struct mdfld_dsi_connector *dsi_connector
  202. = mdfld_dsi_connector(connector);
  203. dsi_connector->status = connector_status_connected;
  204. return dsi_connector->status;
  205. }
  206. static int mdfld_dsi_connector_set_property(struct drm_connector *connector,
  207. struct drm_property *property,
  208. uint64_t value)
  209. {
  210. struct drm_encoder *encoder = connector->encoder;
  211. struct backlight_device *psb_bd;
  212. if (!strcmp(property->name, "scaling mode") && encoder) {
  213. struct psb_intel_crtc *psb_crtc =
  214. to_psb_intel_crtc(encoder->crtc);
  215. bool centerechange;
  216. uint64_t val;
  217. if (!psb_crtc)
  218. goto set_prop_error;
  219. switch (value) {
  220. case DRM_MODE_SCALE_FULLSCREEN:
  221. break;
  222. case DRM_MODE_SCALE_NO_SCALE:
  223. break;
  224. case DRM_MODE_SCALE_ASPECT:
  225. break;
  226. default:
  227. goto set_prop_error;
  228. }
  229. if (drm_connector_property_get_value(connector, property, &val))
  230. goto set_prop_error;
  231. if (val == value)
  232. goto set_prop_done;
  233. if (drm_connector_property_set_value(connector,
  234. property, value))
  235. goto set_prop_error;
  236. centerechange = (val == DRM_MODE_SCALE_NO_SCALE) ||
  237. (value == DRM_MODE_SCALE_NO_SCALE);
  238. if (psb_crtc->saved_mode.hdisplay != 0 &&
  239. psb_crtc->saved_mode.vdisplay != 0) {
  240. if (centerechange) {
  241. if (!drm_crtc_helper_set_mode(encoder->crtc,
  242. &psb_crtc->saved_mode,
  243. encoder->crtc->x,
  244. encoder->crtc->y,
  245. encoder->crtc->fb))
  246. goto set_prop_error;
  247. } else {
  248. struct drm_encoder_helper_funcs *funcs =
  249. encoder->helper_private;
  250. funcs->mode_set(encoder,
  251. &psb_crtc->saved_mode,
  252. &psb_crtc->saved_adjusted_mode);
  253. }
  254. }
  255. } else if (!strcmp(property->name, "backlight") && encoder) {
  256. if (drm_connector_property_set_value(connector, property,
  257. value))
  258. goto set_prop_error;
  259. else {
  260. psb_bd = mdfld_get_backlight_device();
  261. if (psb_bd) {
  262. psb_bd->props.brightness = value;
  263. mdfld_set_brightness(psb_bd);
  264. }
  265. }
  266. }
  267. set_prop_done:
  268. return 0;
  269. set_prop_error:
  270. return -1;
  271. }
  272. static void mdfld_dsi_connector_destroy(struct drm_connector *connector)
  273. {
  274. struct mdfld_dsi_connector *dsi_connector =
  275. mdfld_dsi_connector(connector);
  276. struct mdfld_dsi_pkg_sender *sender;
  277. if (!dsi_connector)
  278. return;
  279. drm_sysfs_connector_remove(connector);
  280. drm_connector_cleanup(connector);
  281. sender = dsi_connector->pkg_sender;
  282. mdfld_dsi_pkg_sender_destroy(sender);
  283. kfree(dsi_connector);
  284. }
  285. static int mdfld_dsi_connector_get_modes(struct drm_connector *connector)
  286. {
  287. struct mdfld_dsi_connector *dsi_connector =
  288. mdfld_dsi_connector(connector);
  289. struct mdfld_dsi_config *dsi_config =
  290. mdfld_dsi_get_config(dsi_connector);
  291. struct drm_display_mode *fixed_mode = dsi_config->fixed_mode;
  292. struct drm_display_mode *dup_mode = NULL;
  293. struct drm_device *dev = connector->dev;
  294. connector->display_info.min_vfreq = 0;
  295. connector->display_info.max_vfreq = 200;
  296. connector->display_info.min_hfreq = 0;
  297. connector->display_info.max_hfreq = 200;
  298. if (fixed_mode) {
  299. dev_dbg(dev->dev, "fixed_mode %dx%d\n",
  300. fixed_mode->hdisplay, fixed_mode->vdisplay);
  301. dup_mode = drm_mode_duplicate(dev, fixed_mode);
  302. drm_mode_probed_add(connector, dup_mode);
  303. return 1;
  304. }
  305. DRM_ERROR("Didn't get any modes!\n");
  306. return 0;
  307. }
  308. static int mdfld_dsi_connector_mode_valid(struct drm_connector *connector,
  309. struct drm_display_mode *mode)
  310. {
  311. struct mdfld_dsi_connector *dsi_connector =
  312. mdfld_dsi_connector(connector);
  313. struct mdfld_dsi_config *dsi_config =
  314. mdfld_dsi_get_config(dsi_connector);
  315. struct drm_display_mode *fixed_mode = dsi_config->fixed_mode;
  316. if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
  317. return MODE_NO_DBLESCAN;
  318. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  319. return MODE_NO_INTERLACE;
  320. /**
  321. * FIXME: current DC has no fitting unit, reject any mode setting
  322. * request
  323. * Will figure out a way to do up-scaling(pannel fitting) later.
  324. **/
  325. if (fixed_mode) {
  326. if (mode->hdisplay != fixed_mode->hdisplay)
  327. return MODE_PANEL;
  328. if (mode->vdisplay != fixed_mode->vdisplay)
  329. return MODE_PANEL;
  330. }
  331. return MODE_OK;
  332. }
  333. static void mdfld_dsi_connector_dpms(struct drm_connector *connector, int mode)
  334. {
  335. if (mode == connector->dpms)
  336. return;
  337. /*first, execute dpms*/
  338. drm_helper_connector_dpms(connector, mode);
  339. }
  340. static struct drm_encoder *mdfld_dsi_connector_best_encoder(
  341. struct drm_connector *connector)
  342. {
  343. struct mdfld_dsi_connector *dsi_connector =
  344. mdfld_dsi_connector(connector);
  345. struct mdfld_dsi_config *dsi_config =
  346. mdfld_dsi_get_config(dsi_connector);
  347. return &dsi_config->encoder->base.base;
  348. }
  349. /*DSI connector funcs*/
  350. static const struct drm_connector_funcs mdfld_dsi_connector_funcs = {
  351. .dpms = /*drm_helper_connector_dpms*/mdfld_dsi_connector_dpms,
  352. .save = mdfld_dsi_connector_save,
  353. .restore = mdfld_dsi_connector_restore,
  354. .detect = mdfld_dsi_connector_detect,
  355. .fill_modes = drm_helper_probe_single_connector_modes,
  356. .set_property = mdfld_dsi_connector_set_property,
  357. .destroy = mdfld_dsi_connector_destroy,
  358. };
  359. /*DSI connector helper funcs*/
  360. static const struct drm_connector_helper_funcs
  361. mdfld_dsi_connector_helper_funcs = {
  362. .get_modes = mdfld_dsi_connector_get_modes,
  363. .mode_valid = mdfld_dsi_connector_mode_valid,
  364. .best_encoder = mdfld_dsi_connector_best_encoder,
  365. };
  366. static int mdfld_dsi_get_default_config(struct drm_device *dev,
  367. struct mdfld_dsi_config *config, int pipe)
  368. {
  369. if (!dev || !config) {
  370. DRM_ERROR("Invalid parameters");
  371. return -EINVAL;
  372. }
  373. config->bpp = 24;
  374. if (mdfld_get_panel_type(dev, pipe) == TC35876X)
  375. config->lane_count = 4;
  376. else
  377. config->lane_count = 2;
  378. config->channel_num = 0;
  379. if (mdfld_get_panel_type(dev, pipe) == TMD_VID)
  380. config->video_mode = MDFLD_DSI_VIDEO_NON_BURST_MODE_SYNC_PULSE;
  381. else if (mdfld_get_panel_type(dev, pipe) == TC35876X)
  382. config->video_mode =
  383. MDFLD_DSI_VIDEO_NON_BURST_MODE_SYNC_EVENTS;
  384. else
  385. config->video_mode = MDFLD_DSI_VIDEO_BURST_MODE;
  386. return 0;
  387. }
  388. int mdfld_dsi_panel_reset(int pipe)
  389. {
  390. unsigned gpio;
  391. int ret = 0;
  392. switch (pipe) {
  393. case 0:
  394. gpio = 128;
  395. break;
  396. case 2:
  397. gpio = 34;
  398. break;
  399. default:
  400. DRM_ERROR("Invalid output\n");
  401. return -EINVAL;
  402. }
  403. ret = gpio_request(gpio, "gfx");
  404. if (ret) {
  405. DRM_ERROR("gpio_rqueset failed\n");
  406. return ret;
  407. }
  408. ret = gpio_direction_output(gpio, 1);
  409. if (ret) {
  410. DRM_ERROR("gpio_direction_output failed\n");
  411. goto gpio_error;
  412. }
  413. gpio_get_value(128);
  414. gpio_error:
  415. if (gpio_is_valid(gpio))
  416. gpio_free(gpio);
  417. return ret;
  418. }
  419. /*
  420. * MIPI output init
  421. * @dev drm device
  422. * @pipe pipe number. 0 or 2
  423. * @config
  424. *
  425. * Do the initialization of a MIPI output, including create DRM mode objects
  426. * initialization of DSI output on @pipe
  427. */
  428. void mdfld_dsi_output_init(struct drm_device *dev,
  429. int pipe,
  430. const struct panel_funcs *p_vid_funcs)
  431. {
  432. struct mdfld_dsi_config *dsi_config;
  433. struct mdfld_dsi_connector *dsi_connector;
  434. struct drm_connector *connector;
  435. struct mdfld_dsi_encoder *encoder;
  436. struct drm_psb_private *dev_priv = dev->dev_private;
  437. struct panel_info dsi_panel_info;
  438. u32 width_mm, height_mm;
  439. dev_dbg(dev->dev, "init DSI output on pipe %d\n", pipe);
  440. if (!dev || ((pipe != 0) && (pipe != 2))) {
  441. DRM_ERROR("Invalid parameter\n");
  442. return;
  443. }
  444. /*create a new connetor*/
  445. dsi_connector = kzalloc(sizeof(struct mdfld_dsi_connector), GFP_KERNEL);
  446. if (!dsi_connector) {
  447. DRM_ERROR("No memory");
  448. return;
  449. }
  450. dsi_connector->pipe = pipe;
  451. dsi_config = kzalloc(sizeof(struct mdfld_dsi_config),
  452. GFP_KERNEL);
  453. if (!dsi_config) {
  454. DRM_ERROR("cannot allocate memory for DSI config\n");
  455. goto dsi_init_err0;
  456. }
  457. mdfld_dsi_get_default_config(dev, dsi_config, pipe);
  458. dsi_connector->private = dsi_config;
  459. dsi_config->changed = 1;
  460. dsi_config->dev = dev;
  461. dsi_config->fixed_mode = p_vid_funcs->get_config_mode(dev);
  462. if (p_vid_funcs->get_panel_info(dev, pipe, &dsi_panel_info))
  463. goto dsi_init_err0;
  464. width_mm = dsi_panel_info.width_mm;
  465. height_mm = dsi_panel_info.height_mm;
  466. dsi_config->mode = dsi_config->fixed_mode;
  467. dsi_config->connector = dsi_connector;
  468. if (!dsi_config->fixed_mode) {
  469. DRM_ERROR("No pannel fixed mode was found\n");
  470. goto dsi_init_err0;
  471. }
  472. if (pipe && dev_priv->dsi_configs[0]) {
  473. dsi_config->dvr_ic_inited = 0;
  474. dev_priv->dsi_configs[1] = dsi_config;
  475. } else if (pipe == 0) {
  476. dsi_config->dvr_ic_inited = 1;
  477. dev_priv->dsi_configs[0] = dsi_config;
  478. } else {
  479. DRM_ERROR("Trying to init MIPI1 before MIPI0\n");
  480. goto dsi_init_err0;
  481. }
  482. connector = &dsi_connector->base.base;
  483. drm_connector_init(dev, connector, &mdfld_dsi_connector_funcs,
  484. DRM_MODE_CONNECTOR_LVDS);
  485. drm_connector_helper_add(connector, &mdfld_dsi_connector_helper_funcs);
  486. connector->display_info.subpixel_order = SubPixelHorizontalRGB;
  487. connector->display_info.width_mm = width_mm;
  488. connector->display_info.height_mm = height_mm;
  489. connector->interlace_allowed = false;
  490. connector->doublescan_allowed = false;
  491. /*attach properties*/
  492. drm_connector_attach_property(connector,
  493. dev->mode_config.scaling_mode_property,
  494. DRM_MODE_SCALE_FULLSCREEN);
  495. drm_connector_attach_property(connector,
  496. dev_priv->backlight_property,
  497. MDFLD_DSI_BRIGHTNESS_MAX_LEVEL);
  498. /*init DSI package sender on this output*/
  499. if (mdfld_dsi_pkg_sender_init(dsi_connector, pipe)) {
  500. DRM_ERROR("Package Sender initialization failed on pipe %d\n",
  501. pipe);
  502. goto dsi_init_err0;
  503. }
  504. encoder = mdfld_dsi_dpi_init(dev, dsi_connector, p_vid_funcs);
  505. if (!encoder) {
  506. DRM_ERROR("Create DPI encoder failed\n");
  507. goto dsi_init_err1;
  508. }
  509. encoder->private = dsi_config;
  510. dsi_config->encoder = encoder;
  511. encoder->base.type = (pipe == 0) ? INTEL_OUTPUT_MIPI :
  512. INTEL_OUTPUT_MIPI2;
  513. drm_sysfs_connector_add(connector);
  514. return;
  515. /*TODO: add code to destroy outputs on error*/
  516. dsi_init_err1:
  517. /*destroy sender*/
  518. mdfld_dsi_pkg_sender_destroy(dsi_connector->pkg_sender);
  519. drm_connector_cleanup(connector);
  520. kfree(dsi_config->fixed_mode);
  521. kfree(dsi_config);
  522. dsi_init_err0:
  523. kfree(dsi_connector);
  524. }