overlay.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /*
  2. * linux/drivers/video/omap2/dss/overlay.c
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  6. *
  7. * Some code and ideas taken from drivers/video/omap/ driver
  8. * by Imre Deak.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #define DSS_SUBSYS_NAME "OVERLAY"
  23. #include <linux/kernel.h>
  24. #include <linux/module.h>
  25. #include <linux/err.h>
  26. #include <linux/sysfs.h>
  27. #include <linux/kobject.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/delay.h>
  30. #include <linux/slab.h>
  31. #include <video/omapdss.h>
  32. #include <plat/cpu.h>
  33. #include "dss.h"
  34. #include "dss_features.h"
  35. static int num_overlays;
  36. static struct list_head overlay_list;
  37. static ssize_t overlay_name_show(struct omap_overlay *ovl, char *buf)
  38. {
  39. return snprintf(buf, PAGE_SIZE, "%s\n", ovl->name);
  40. }
  41. static ssize_t overlay_manager_show(struct omap_overlay *ovl, char *buf)
  42. {
  43. return snprintf(buf, PAGE_SIZE, "%s\n",
  44. ovl->manager ? ovl->manager->name : "<none>");
  45. }
  46. static ssize_t overlay_manager_store(struct omap_overlay *ovl, const char *buf,
  47. size_t size)
  48. {
  49. int i, r;
  50. struct omap_overlay_manager *mgr = NULL;
  51. struct omap_overlay_manager *old_mgr;
  52. int len = size;
  53. if (buf[size-1] == '\n')
  54. --len;
  55. if (len > 0) {
  56. for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
  57. mgr = omap_dss_get_overlay_manager(i);
  58. if (sysfs_streq(buf, mgr->name))
  59. break;
  60. mgr = NULL;
  61. }
  62. }
  63. if (len > 0 && mgr == NULL)
  64. return -EINVAL;
  65. if (mgr)
  66. DSSDBG("manager %s found\n", mgr->name);
  67. if (mgr == ovl->manager)
  68. return size;
  69. old_mgr = ovl->manager;
  70. /* detach old manager */
  71. if (old_mgr) {
  72. r = ovl->unset_manager(ovl);
  73. if (r) {
  74. DSSERR("detach failed\n");
  75. return r;
  76. }
  77. r = old_mgr->apply(old_mgr);
  78. if (r)
  79. return r;
  80. }
  81. if (mgr) {
  82. r = ovl->set_manager(ovl, mgr);
  83. if (r) {
  84. DSSERR("Failed to attach overlay\n");
  85. return r;
  86. }
  87. r = mgr->apply(mgr);
  88. if (r)
  89. return r;
  90. }
  91. return size;
  92. }
  93. static ssize_t overlay_input_size_show(struct omap_overlay *ovl, char *buf)
  94. {
  95. return snprintf(buf, PAGE_SIZE, "%d,%d\n",
  96. ovl->info.width, ovl->info.height);
  97. }
  98. static ssize_t overlay_screen_width_show(struct omap_overlay *ovl, char *buf)
  99. {
  100. return snprintf(buf, PAGE_SIZE, "%d\n", ovl->info.screen_width);
  101. }
  102. static ssize_t overlay_position_show(struct omap_overlay *ovl, char *buf)
  103. {
  104. return snprintf(buf, PAGE_SIZE, "%d,%d\n",
  105. ovl->info.pos_x, ovl->info.pos_y);
  106. }
  107. static ssize_t overlay_position_store(struct omap_overlay *ovl,
  108. const char *buf, size_t size)
  109. {
  110. int r;
  111. char *last;
  112. struct omap_overlay_info info;
  113. ovl->get_overlay_info(ovl, &info);
  114. info.pos_x = simple_strtoul(buf, &last, 10);
  115. ++last;
  116. if (last - buf >= size)
  117. return -EINVAL;
  118. info.pos_y = simple_strtoul(last, &last, 10);
  119. r = ovl->set_overlay_info(ovl, &info);
  120. if (r)
  121. return r;
  122. if (ovl->manager) {
  123. r = ovl->manager->apply(ovl->manager);
  124. if (r)
  125. return r;
  126. }
  127. return size;
  128. }
  129. static ssize_t overlay_output_size_show(struct omap_overlay *ovl, char *buf)
  130. {
  131. return snprintf(buf, PAGE_SIZE, "%d,%d\n",
  132. ovl->info.out_width, ovl->info.out_height);
  133. }
  134. static ssize_t overlay_output_size_store(struct omap_overlay *ovl,
  135. const char *buf, size_t size)
  136. {
  137. int r;
  138. char *last;
  139. struct omap_overlay_info info;
  140. ovl->get_overlay_info(ovl, &info);
  141. info.out_width = simple_strtoul(buf, &last, 10);
  142. ++last;
  143. if (last - buf >= size)
  144. return -EINVAL;
  145. info.out_height = simple_strtoul(last, &last, 10);
  146. r = ovl->set_overlay_info(ovl, &info);
  147. if (r)
  148. return r;
  149. if (ovl->manager) {
  150. r = ovl->manager->apply(ovl->manager);
  151. if (r)
  152. return r;
  153. }
  154. return size;
  155. }
  156. static ssize_t overlay_enabled_show(struct omap_overlay *ovl, char *buf)
  157. {
  158. return snprintf(buf, PAGE_SIZE, "%d\n", ovl->info.enabled);
  159. }
  160. static ssize_t overlay_enabled_store(struct omap_overlay *ovl, const char *buf,
  161. size_t size)
  162. {
  163. int r, enable;
  164. struct omap_overlay_info info;
  165. ovl->get_overlay_info(ovl, &info);
  166. r = kstrtoint(buf, 0, &enable);
  167. if (r)
  168. return r;
  169. info.enabled = !!enable;
  170. r = ovl->set_overlay_info(ovl, &info);
  171. if (r)
  172. return r;
  173. if (ovl->manager) {
  174. r = ovl->manager->apply(ovl->manager);
  175. if (r)
  176. return r;
  177. }
  178. return size;
  179. }
  180. static ssize_t overlay_global_alpha_show(struct omap_overlay *ovl, char *buf)
  181. {
  182. return snprintf(buf, PAGE_SIZE, "%d\n",
  183. ovl->info.global_alpha);
  184. }
  185. static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,
  186. const char *buf, size_t size)
  187. {
  188. int r;
  189. u8 alpha;
  190. struct omap_overlay_info info;
  191. r = kstrtou8(buf, 0, &alpha);
  192. if (r)
  193. return r;
  194. ovl->get_overlay_info(ovl, &info);
  195. /* Video1 plane does not support global alpha
  196. * to always make it 255 completely opaque
  197. */
  198. if (!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
  199. ovl->id == OMAP_DSS_VIDEO1)
  200. info.global_alpha = 255;
  201. else
  202. info.global_alpha = alpha;
  203. r = ovl->set_overlay_info(ovl, &info);
  204. if (r)
  205. return r;
  206. if (ovl->manager) {
  207. r = ovl->manager->apply(ovl->manager);
  208. if (r)
  209. return r;
  210. }
  211. return size;
  212. }
  213. static ssize_t overlay_pre_mult_alpha_show(struct omap_overlay *ovl,
  214. char *buf)
  215. {
  216. return snprintf(buf, PAGE_SIZE, "%d\n",
  217. ovl->info.pre_mult_alpha);
  218. }
  219. static ssize_t overlay_pre_mult_alpha_store(struct omap_overlay *ovl,
  220. const char *buf, size_t size)
  221. {
  222. int r;
  223. u8 alpha;
  224. struct omap_overlay_info info;
  225. r = kstrtou8(buf, 0, &alpha);
  226. if (r)
  227. return r;
  228. ovl->get_overlay_info(ovl, &info);
  229. /* only GFX and Video2 plane support pre alpha multiplied
  230. * set zero for Video1 plane
  231. */
  232. if (!dss_has_feature(FEAT_GLOBAL_ALPHA_VID1) &&
  233. ovl->id == OMAP_DSS_VIDEO1)
  234. info.pre_mult_alpha = 0;
  235. else
  236. info.pre_mult_alpha = alpha;
  237. r = ovl->set_overlay_info(ovl, &info);
  238. if (r)
  239. return r;
  240. if (ovl->manager) {
  241. r = ovl->manager->apply(ovl->manager);
  242. if (r)
  243. return r;
  244. }
  245. return size;
  246. }
  247. struct overlay_attribute {
  248. struct attribute attr;
  249. ssize_t (*show)(struct omap_overlay *, char *);
  250. ssize_t (*store)(struct omap_overlay *, const char *, size_t);
  251. };
  252. #define OVERLAY_ATTR(_name, _mode, _show, _store) \
  253. struct overlay_attribute overlay_attr_##_name = \
  254. __ATTR(_name, _mode, _show, _store)
  255. static OVERLAY_ATTR(name, S_IRUGO, overlay_name_show, NULL);
  256. static OVERLAY_ATTR(manager, S_IRUGO|S_IWUSR,
  257. overlay_manager_show, overlay_manager_store);
  258. static OVERLAY_ATTR(input_size, S_IRUGO, overlay_input_size_show, NULL);
  259. static OVERLAY_ATTR(screen_width, S_IRUGO, overlay_screen_width_show, NULL);
  260. static OVERLAY_ATTR(position, S_IRUGO|S_IWUSR,
  261. overlay_position_show, overlay_position_store);
  262. static OVERLAY_ATTR(output_size, S_IRUGO|S_IWUSR,
  263. overlay_output_size_show, overlay_output_size_store);
  264. static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
  265. overlay_enabled_show, overlay_enabled_store);
  266. static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
  267. overlay_global_alpha_show, overlay_global_alpha_store);
  268. static OVERLAY_ATTR(pre_mult_alpha, S_IRUGO|S_IWUSR,
  269. overlay_pre_mult_alpha_show,
  270. overlay_pre_mult_alpha_store);
  271. static struct attribute *overlay_sysfs_attrs[] = {
  272. &overlay_attr_name.attr,
  273. &overlay_attr_manager.attr,
  274. &overlay_attr_input_size.attr,
  275. &overlay_attr_screen_width.attr,
  276. &overlay_attr_position.attr,
  277. &overlay_attr_output_size.attr,
  278. &overlay_attr_enabled.attr,
  279. &overlay_attr_global_alpha.attr,
  280. &overlay_attr_pre_mult_alpha.attr,
  281. NULL
  282. };
  283. static ssize_t overlay_attr_show(struct kobject *kobj, struct attribute *attr,
  284. char *buf)
  285. {
  286. struct omap_overlay *overlay;
  287. struct overlay_attribute *overlay_attr;
  288. overlay = container_of(kobj, struct omap_overlay, kobj);
  289. overlay_attr = container_of(attr, struct overlay_attribute, attr);
  290. if (!overlay_attr->show)
  291. return -ENOENT;
  292. return overlay_attr->show(overlay, buf);
  293. }
  294. static ssize_t overlay_attr_store(struct kobject *kobj, struct attribute *attr,
  295. const char *buf, size_t size)
  296. {
  297. struct omap_overlay *overlay;
  298. struct overlay_attribute *overlay_attr;
  299. overlay = container_of(kobj, struct omap_overlay, kobj);
  300. overlay_attr = container_of(attr, struct overlay_attribute, attr);
  301. if (!overlay_attr->store)
  302. return -ENOENT;
  303. return overlay_attr->store(overlay, buf, size);
  304. }
  305. static const struct sysfs_ops overlay_sysfs_ops = {
  306. .show = overlay_attr_show,
  307. .store = overlay_attr_store,
  308. };
  309. static struct kobj_type overlay_ktype = {
  310. .sysfs_ops = &overlay_sysfs_ops,
  311. .default_attrs = overlay_sysfs_attrs,
  312. };
  313. /* Check if overlay parameters are compatible with display */
  314. int dss_check_overlay(struct omap_overlay *ovl, struct omap_dss_device *dssdev)
  315. {
  316. struct omap_overlay_info *info;
  317. u16 outw, outh;
  318. u16 dw, dh;
  319. if (!dssdev)
  320. return 0;
  321. if (!ovl->info.enabled)
  322. return 0;
  323. info = &ovl->info;
  324. if (info->paddr == 0) {
  325. DSSDBG("check_overlay failed: paddr 0\n");
  326. return -EINVAL;
  327. }
  328. dssdev->driver->get_resolution(dssdev, &dw, &dh);
  329. DSSDBG("check_overlay %d: (%d,%d %dx%d -> %dx%d) disp (%dx%d)\n",
  330. ovl->id,
  331. info->pos_x, info->pos_y,
  332. info->width, info->height,
  333. info->out_width, info->out_height,
  334. dw, dh);
  335. if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
  336. outw = info->width;
  337. outh = info->height;
  338. } else {
  339. if (info->out_width == 0)
  340. outw = info->width;
  341. else
  342. outw = info->out_width;
  343. if (info->out_height == 0)
  344. outh = info->height;
  345. else
  346. outh = info->out_height;
  347. }
  348. if (dw < info->pos_x + outw) {
  349. DSSDBG("check_overlay failed 1: %d < %d + %d\n",
  350. dw, info->pos_x, outw);
  351. return -EINVAL;
  352. }
  353. if (dh < info->pos_y + outh) {
  354. DSSDBG("check_overlay failed 2: %d < %d + %d\n",
  355. dh, info->pos_y, outh);
  356. return -EINVAL;
  357. }
  358. if ((ovl->supported_modes & info->color_mode) == 0) {
  359. DSSERR("overlay doesn't support mode %d\n", info->color_mode);
  360. return -EINVAL;
  361. }
  362. return 0;
  363. }
  364. static int dss_ovl_set_overlay_info(struct omap_overlay *ovl,
  365. struct omap_overlay_info *info)
  366. {
  367. int r;
  368. struct omap_overlay_info old_info;
  369. old_info = ovl->info;
  370. ovl->info = *info;
  371. if (ovl->manager) {
  372. r = dss_check_overlay(ovl, ovl->manager->device);
  373. if (r) {
  374. ovl->info = old_info;
  375. return r;
  376. }
  377. }
  378. ovl->info_dirty = true;
  379. return 0;
  380. }
  381. static void dss_ovl_get_overlay_info(struct omap_overlay *ovl,
  382. struct omap_overlay_info *info)
  383. {
  384. *info = ovl->info;
  385. }
  386. static int dss_ovl_wait_for_go(struct omap_overlay *ovl)
  387. {
  388. return dss_mgr_wait_for_go_ovl(ovl);
  389. }
  390. static int omap_dss_set_manager(struct omap_overlay *ovl,
  391. struct omap_overlay_manager *mgr)
  392. {
  393. if (!mgr)
  394. return -EINVAL;
  395. if (ovl->manager) {
  396. DSSERR("overlay '%s' already has a manager '%s'\n",
  397. ovl->name, ovl->manager->name);
  398. return -EINVAL;
  399. }
  400. if (ovl->info.enabled) {
  401. DSSERR("overlay has to be disabled to change the manager\n");
  402. return -EINVAL;
  403. }
  404. ovl->manager = mgr;
  405. dss_clk_enable(DSS_CLK_ICK | DSS_CLK_FCK);
  406. /* XXX: When there is an overlay on a DSI manual update display, and
  407. * the overlay is first disabled, then moved to tv, and enabled, we
  408. * seem to get SYNC_LOST_DIGIT error.
  409. *
  410. * Waiting doesn't seem to help, but updating the manual update display
  411. * after disabling the overlay seems to fix this. This hints that the
  412. * overlay is perhaps somehow tied to the LCD output until the output
  413. * is updated.
  414. *
  415. * Userspace workaround for this is to update the LCD after disabling
  416. * the overlay, but before moving the overlay to TV.
  417. */
  418. dispc_set_channel_out(ovl->id, mgr->id);
  419. dss_clk_disable(DSS_CLK_ICK | DSS_CLK_FCK);
  420. return 0;
  421. }
  422. static int omap_dss_unset_manager(struct omap_overlay *ovl)
  423. {
  424. int r;
  425. if (!ovl->manager) {
  426. DSSERR("failed to detach overlay: manager not set\n");
  427. return -EINVAL;
  428. }
  429. if (ovl->info.enabled) {
  430. DSSERR("overlay has to be disabled to unset the manager\n");
  431. return -EINVAL;
  432. }
  433. r = ovl->wait_for_go(ovl);
  434. if (r)
  435. return r;
  436. ovl->manager = NULL;
  437. return 0;
  438. }
  439. int omap_dss_get_num_overlays(void)
  440. {
  441. return num_overlays;
  442. }
  443. EXPORT_SYMBOL(omap_dss_get_num_overlays);
  444. struct omap_overlay *omap_dss_get_overlay(int num)
  445. {
  446. int i = 0;
  447. struct omap_overlay *ovl;
  448. list_for_each_entry(ovl, &overlay_list, list) {
  449. if (i++ == num)
  450. return ovl;
  451. }
  452. return NULL;
  453. }
  454. EXPORT_SYMBOL(omap_dss_get_overlay);
  455. static void omap_dss_add_overlay(struct omap_overlay *overlay)
  456. {
  457. ++num_overlays;
  458. list_add_tail(&overlay->list, &overlay_list);
  459. }
  460. static struct omap_overlay *dispc_overlays[MAX_DSS_OVERLAYS];
  461. void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr)
  462. {
  463. mgr->num_overlays = dss_feat_get_num_ovls();
  464. mgr->overlays = dispc_overlays;
  465. }
  466. #ifdef L4_EXAMPLE
  467. static struct omap_overlay *l4_overlays[1];
  468. void dss_overlay_setup_l4_manager(struct omap_overlay_manager *mgr)
  469. {
  470. mgr->num_overlays = 1;
  471. mgr->overlays = l4_overlays;
  472. }
  473. #endif
  474. void dss_init_overlays(struct platform_device *pdev)
  475. {
  476. int i, r;
  477. INIT_LIST_HEAD(&overlay_list);
  478. num_overlays = 0;
  479. for (i = 0; i < dss_feat_get_num_ovls(); ++i) {
  480. struct omap_overlay *ovl;
  481. ovl = kzalloc(sizeof(*ovl), GFP_KERNEL);
  482. BUG_ON(ovl == NULL);
  483. switch (i) {
  484. case 0:
  485. ovl->name = "gfx";
  486. ovl->id = OMAP_DSS_GFX;
  487. ovl->caps = OMAP_DSS_OVL_CAP_DISPC;
  488. ovl->info.global_alpha = 255;
  489. break;
  490. case 1:
  491. ovl->name = "vid1";
  492. ovl->id = OMAP_DSS_VIDEO1;
  493. ovl->caps = OMAP_DSS_OVL_CAP_SCALE |
  494. OMAP_DSS_OVL_CAP_DISPC;
  495. ovl->info.global_alpha = 255;
  496. break;
  497. case 2:
  498. ovl->name = "vid2";
  499. ovl->id = OMAP_DSS_VIDEO2;
  500. ovl->caps = OMAP_DSS_OVL_CAP_SCALE |
  501. OMAP_DSS_OVL_CAP_DISPC;
  502. ovl->info.global_alpha = 255;
  503. break;
  504. }
  505. ovl->set_manager = &omap_dss_set_manager;
  506. ovl->unset_manager = &omap_dss_unset_manager;
  507. ovl->set_overlay_info = &dss_ovl_set_overlay_info;
  508. ovl->get_overlay_info = &dss_ovl_get_overlay_info;
  509. ovl->wait_for_go = &dss_ovl_wait_for_go;
  510. ovl->supported_modes =
  511. dss_feat_get_supported_color_modes(ovl->id);
  512. omap_dss_add_overlay(ovl);
  513. r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
  514. &pdev->dev.kobj, "overlay%d", i);
  515. if (r) {
  516. DSSERR("failed to create sysfs file\n");
  517. continue;
  518. }
  519. dispc_overlays[i] = ovl;
  520. }
  521. #ifdef L4_EXAMPLE
  522. {
  523. struct omap_overlay *ovl;
  524. ovl = kzalloc(sizeof(*ovl), GFP_KERNEL);
  525. BUG_ON(ovl == NULL);
  526. ovl->name = "l4";
  527. ovl->supported_modes = OMAP_DSS_COLOR_RGB24U;
  528. ovl->set_manager = &omap_dss_set_manager;
  529. ovl->unset_manager = &omap_dss_unset_manager;
  530. ovl->set_overlay_info = &dss_ovl_set_overlay_info;
  531. ovl->get_overlay_info = &dss_ovl_get_overlay_info;
  532. omap_dss_add_overlay(ovl);
  533. r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
  534. &pdev->dev.kobj, "overlayl4");
  535. if (r)
  536. DSSERR("failed to create sysfs file\n");
  537. l4_overlays[0] = ovl;
  538. }
  539. #endif
  540. }
  541. /* connect overlays to the new device, if not already connected. if force
  542. * selected, connect always. */
  543. void dss_recheck_connections(struct omap_dss_device *dssdev, bool force)
  544. {
  545. int i;
  546. struct omap_overlay_manager *lcd_mgr;
  547. struct omap_overlay_manager *tv_mgr;
  548. struct omap_overlay_manager *lcd2_mgr = NULL;
  549. struct omap_overlay_manager *mgr = NULL;
  550. lcd_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_LCD);
  551. tv_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_TV);
  552. if (dss_has_feature(FEAT_MGR_LCD2))
  553. lcd2_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_LCD2);
  554. if (dssdev->channel == OMAP_DSS_CHANNEL_LCD2) {
  555. if (!lcd2_mgr->device || force) {
  556. if (lcd2_mgr->device)
  557. lcd2_mgr->unset_device(lcd2_mgr);
  558. lcd2_mgr->set_device(lcd2_mgr, dssdev);
  559. mgr = lcd2_mgr;
  560. }
  561. } else if (dssdev->type != OMAP_DISPLAY_TYPE_VENC
  562. && dssdev->type != OMAP_DISPLAY_TYPE_HDMI) {
  563. if (!lcd_mgr->device || force) {
  564. if (lcd_mgr->device)
  565. lcd_mgr->unset_device(lcd_mgr);
  566. lcd_mgr->set_device(lcd_mgr, dssdev);
  567. mgr = lcd_mgr;
  568. }
  569. }
  570. if (dssdev->type == OMAP_DISPLAY_TYPE_VENC
  571. || dssdev->type == OMAP_DISPLAY_TYPE_HDMI) {
  572. if (!tv_mgr->device || force) {
  573. if (tv_mgr->device)
  574. tv_mgr->unset_device(tv_mgr);
  575. tv_mgr->set_device(tv_mgr, dssdev);
  576. mgr = tv_mgr;
  577. }
  578. }
  579. if (mgr) {
  580. for (i = 0; i < dss_feat_get_num_ovls(); i++) {
  581. struct omap_overlay *ovl;
  582. ovl = omap_dss_get_overlay(i);
  583. if (!ovl->manager || force) {
  584. if (ovl->manager)
  585. omap_dss_unset_manager(ovl);
  586. omap_dss_set_manager(ovl, mgr);
  587. }
  588. }
  589. }
  590. }
  591. void dss_uninit_overlays(struct platform_device *pdev)
  592. {
  593. struct omap_overlay *ovl;
  594. while (!list_empty(&overlay_list)) {
  595. ovl = list_first_entry(&overlay_list,
  596. struct omap_overlay, list);
  597. list_del(&ovl->list);
  598. kobject_del(&ovl->kobj);
  599. kobject_put(&ovl->kobj);
  600. kfree(ovl);
  601. }
  602. num_overlays = 0;
  603. }