overlay.c 17 KB

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