overlay.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  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 ((ovl->caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
  199. return -ENODEV;
  200. r = kstrtou8(buf, 0, &alpha);
  201. if (r)
  202. return r;
  203. ovl->get_overlay_info(ovl, &info);
  204. info.global_alpha = alpha;
  205. r = ovl->set_overlay_info(ovl, &info);
  206. if (r)
  207. return r;
  208. if (ovl->manager) {
  209. r = ovl->manager->apply(ovl->manager);
  210. if (r)
  211. return r;
  212. }
  213. return size;
  214. }
  215. static ssize_t overlay_pre_mult_alpha_show(struct omap_overlay *ovl,
  216. char *buf)
  217. {
  218. return snprintf(buf, PAGE_SIZE, "%d\n",
  219. ovl->info.pre_mult_alpha);
  220. }
  221. static ssize_t overlay_pre_mult_alpha_store(struct omap_overlay *ovl,
  222. const char *buf, size_t size)
  223. {
  224. int r;
  225. u8 alpha;
  226. struct omap_overlay_info info;
  227. if ((ovl->caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
  228. return -ENODEV;
  229. r = kstrtou8(buf, 0, &alpha);
  230. if (r)
  231. return r;
  232. ovl->get_overlay_info(ovl, &info);
  233. info.pre_mult_alpha = alpha;
  234. r = ovl->set_overlay_info(ovl, &info);
  235. if (r)
  236. return r;
  237. if (ovl->manager) {
  238. r = ovl->manager->apply(ovl->manager);
  239. if (r)
  240. return r;
  241. }
  242. return size;
  243. }
  244. struct overlay_attribute {
  245. struct attribute attr;
  246. ssize_t (*show)(struct omap_overlay *, char *);
  247. ssize_t (*store)(struct omap_overlay *, const char *, size_t);
  248. };
  249. #define OVERLAY_ATTR(_name, _mode, _show, _store) \
  250. struct overlay_attribute overlay_attr_##_name = \
  251. __ATTR(_name, _mode, _show, _store)
  252. static OVERLAY_ATTR(name, S_IRUGO, overlay_name_show, NULL);
  253. static OVERLAY_ATTR(manager, S_IRUGO|S_IWUSR,
  254. overlay_manager_show, overlay_manager_store);
  255. static OVERLAY_ATTR(input_size, S_IRUGO, overlay_input_size_show, NULL);
  256. static OVERLAY_ATTR(screen_width, S_IRUGO, overlay_screen_width_show, NULL);
  257. static OVERLAY_ATTR(position, S_IRUGO|S_IWUSR,
  258. overlay_position_show, overlay_position_store);
  259. static OVERLAY_ATTR(output_size, S_IRUGO|S_IWUSR,
  260. overlay_output_size_show, overlay_output_size_store);
  261. static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
  262. overlay_enabled_show, overlay_enabled_store);
  263. static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
  264. overlay_global_alpha_show, overlay_global_alpha_store);
  265. static OVERLAY_ATTR(pre_mult_alpha, S_IRUGO|S_IWUSR,
  266. overlay_pre_mult_alpha_show,
  267. overlay_pre_mult_alpha_store);
  268. static struct attribute *overlay_sysfs_attrs[] = {
  269. &overlay_attr_name.attr,
  270. &overlay_attr_manager.attr,
  271. &overlay_attr_input_size.attr,
  272. &overlay_attr_screen_width.attr,
  273. &overlay_attr_position.attr,
  274. &overlay_attr_output_size.attr,
  275. &overlay_attr_enabled.attr,
  276. &overlay_attr_global_alpha.attr,
  277. &overlay_attr_pre_mult_alpha.attr,
  278. NULL
  279. };
  280. static ssize_t overlay_attr_show(struct kobject *kobj, struct attribute *attr,
  281. char *buf)
  282. {
  283. struct omap_overlay *overlay;
  284. struct overlay_attribute *overlay_attr;
  285. overlay = container_of(kobj, struct omap_overlay, kobj);
  286. overlay_attr = container_of(attr, struct overlay_attribute, attr);
  287. if (!overlay_attr->show)
  288. return -ENOENT;
  289. return overlay_attr->show(overlay, buf);
  290. }
  291. static ssize_t overlay_attr_store(struct kobject *kobj, struct attribute *attr,
  292. const char *buf, size_t size)
  293. {
  294. struct omap_overlay *overlay;
  295. struct overlay_attribute *overlay_attr;
  296. overlay = container_of(kobj, struct omap_overlay, kobj);
  297. overlay_attr = container_of(attr, struct overlay_attribute, attr);
  298. if (!overlay_attr->store)
  299. return -ENOENT;
  300. return overlay_attr->store(overlay, buf, size);
  301. }
  302. static const struct sysfs_ops overlay_sysfs_ops = {
  303. .show = overlay_attr_show,
  304. .store = overlay_attr_store,
  305. };
  306. static struct kobj_type overlay_ktype = {
  307. .sysfs_ops = &overlay_sysfs_ops,
  308. .default_attrs = overlay_sysfs_attrs,
  309. };
  310. /* Check if overlay parameters are compatible with display */
  311. int dss_check_overlay(struct omap_overlay *ovl, struct omap_dss_device *dssdev)
  312. {
  313. struct omap_overlay_info *info;
  314. u16 outw, outh;
  315. u16 dw, dh;
  316. if (!dssdev)
  317. return 0;
  318. if (!ovl->info.enabled)
  319. return 0;
  320. info = &ovl->info;
  321. if (info->paddr == 0) {
  322. DSSDBG("check_overlay failed: paddr 0\n");
  323. return -EINVAL;
  324. }
  325. dssdev->driver->get_resolution(dssdev, &dw, &dh);
  326. DSSDBG("check_overlay %d: (%d,%d %dx%d -> %dx%d) disp (%dx%d)\n",
  327. ovl->id,
  328. info->pos_x, info->pos_y,
  329. info->width, info->height,
  330. info->out_width, info->out_height,
  331. dw, dh);
  332. if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
  333. outw = info->width;
  334. outh = info->height;
  335. } else {
  336. if (info->out_width == 0)
  337. outw = info->width;
  338. else
  339. outw = info->out_width;
  340. if (info->out_height == 0)
  341. outh = info->height;
  342. else
  343. outh = info->out_height;
  344. }
  345. if (dw < info->pos_x + outw) {
  346. DSSDBG("check_overlay failed 1: %d < %d + %d\n",
  347. dw, info->pos_x, outw);
  348. return -EINVAL;
  349. }
  350. if (dh < info->pos_y + outh) {
  351. DSSDBG("check_overlay failed 2: %d < %d + %d\n",
  352. dh, info->pos_y, outh);
  353. return -EINVAL;
  354. }
  355. if ((ovl->supported_modes & info->color_mode) == 0) {
  356. DSSERR("overlay doesn't support mode %d\n", info->color_mode);
  357. return -EINVAL;
  358. }
  359. return 0;
  360. }
  361. static int dss_ovl_set_overlay_info(struct omap_overlay *ovl,
  362. struct omap_overlay_info *info)
  363. {
  364. int r;
  365. struct omap_overlay_info old_info;
  366. old_info = ovl->info;
  367. ovl->info = *info;
  368. if (ovl->manager) {
  369. r = dss_check_overlay(ovl, ovl->manager->device);
  370. if (r) {
  371. ovl->info = old_info;
  372. return r;
  373. }
  374. }
  375. ovl->info_dirty = true;
  376. return 0;
  377. }
  378. static void dss_ovl_get_overlay_info(struct omap_overlay *ovl,
  379. struct omap_overlay_info *info)
  380. {
  381. *info = ovl->info;
  382. }
  383. static int dss_ovl_wait_for_go(struct omap_overlay *ovl)
  384. {
  385. return dss_mgr_wait_for_go_ovl(ovl);
  386. }
  387. static int omap_dss_set_manager(struct omap_overlay *ovl,
  388. struct omap_overlay_manager *mgr)
  389. {
  390. if (!mgr)
  391. return -EINVAL;
  392. if (ovl->manager) {
  393. DSSERR("overlay '%s' already has a manager '%s'\n",
  394. ovl->name, ovl->manager->name);
  395. return -EINVAL;
  396. }
  397. if (ovl->info.enabled) {
  398. DSSERR("overlay has to be disabled to change the manager\n");
  399. return -EINVAL;
  400. }
  401. ovl->manager = mgr;
  402. ovl->manager_changed = true;
  403. /* XXX: When there is an overlay on a DSI manual update display, and
  404. * the overlay is first disabled, then moved to tv, and enabled, we
  405. * seem to get SYNC_LOST_DIGIT error.
  406. *
  407. * Waiting doesn't seem to help, but updating the manual update display
  408. * after disabling the overlay seems to fix this. This hints that the
  409. * overlay is perhaps somehow tied to the LCD output until the output
  410. * is updated.
  411. *
  412. * Userspace workaround for this is to update the LCD after disabling
  413. * the overlay, but before moving the overlay to TV.
  414. */
  415. return 0;
  416. }
  417. static int omap_dss_unset_manager(struct omap_overlay *ovl)
  418. {
  419. if (!ovl->manager) {
  420. DSSERR("failed to detach overlay: manager not set\n");
  421. return -EINVAL;
  422. }
  423. if (ovl->info.enabled) {
  424. DSSERR("overlay has to be disabled to unset the manager\n");
  425. return -EINVAL;
  426. }
  427. ovl->manager = NULL;
  428. ovl->manager_changed = true;
  429. return 0;
  430. }
  431. int omap_dss_get_num_overlays(void)
  432. {
  433. return num_overlays;
  434. }
  435. EXPORT_SYMBOL(omap_dss_get_num_overlays);
  436. struct omap_overlay *omap_dss_get_overlay(int num)
  437. {
  438. int i = 0;
  439. struct omap_overlay *ovl;
  440. list_for_each_entry(ovl, &overlay_list, list) {
  441. if (i++ == num)
  442. return ovl;
  443. }
  444. return NULL;
  445. }
  446. EXPORT_SYMBOL(omap_dss_get_overlay);
  447. static void omap_dss_add_overlay(struct omap_overlay *overlay)
  448. {
  449. ++num_overlays;
  450. list_add_tail(&overlay->list, &overlay_list);
  451. }
  452. static struct omap_overlay *dispc_overlays[MAX_DSS_OVERLAYS];
  453. void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr)
  454. {
  455. mgr->num_overlays = dss_feat_get_num_ovls();
  456. mgr->overlays = dispc_overlays;
  457. }
  458. #ifdef L4_EXAMPLE
  459. static struct omap_overlay *l4_overlays[1];
  460. void dss_overlay_setup_l4_manager(struct omap_overlay_manager *mgr)
  461. {
  462. mgr->num_overlays = 1;
  463. mgr->overlays = l4_overlays;
  464. }
  465. #endif
  466. void dss_init_overlays(struct platform_device *pdev)
  467. {
  468. int i, r;
  469. INIT_LIST_HEAD(&overlay_list);
  470. num_overlays = 0;
  471. for (i = 0; i < dss_feat_get_num_ovls(); ++i) {
  472. struct omap_overlay *ovl;
  473. ovl = kzalloc(sizeof(*ovl), GFP_KERNEL);
  474. BUG_ON(ovl == NULL);
  475. switch (i) {
  476. case 0:
  477. ovl->name = "gfx";
  478. ovl->id = OMAP_DSS_GFX;
  479. ovl->info.global_alpha = 255;
  480. break;
  481. case 1:
  482. ovl->name = "vid1";
  483. ovl->id = OMAP_DSS_VIDEO1;
  484. ovl->info.global_alpha = 255;
  485. break;
  486. case 2:
  487. ovl->name = "vid2";
  488. ovl->id = OMAP_DSS_VIDEO2;
  489. ovl->info.global_alpha = 255;
  490. break;
  491. }
  492. ovl->set_manager = &omap_dss_set_manager;
  493. ovl->unset_manager = &omap_dss_unset_manager;
  494. ovl->set_overlay_info = &dss_ovl_set_overlay_info;
  495. ovl->get_overlay_info = &dss_ovl_get_overlay_info;
  496. ovl->wait_for_go = &dss_ovl_wait_for_go;
  497. ovl->caps = dss_feat_get_overlay_caps(ovl->id);
  498. ovl->supported_modes =
  499. dss_feat_get_supported_color_modes(ovl->id);
  500. omap_dss_add_overlay(ovl);
  501. r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
  502. &pdev->dev.kobj, "overlay%d", i);
  503. if (r) {
  504. DSSERR("failed to create sysfs file\n");
  505. continue;
  506. }
  507. dispc_overlays[i] = ovl;
  508. }
  509. #ifdef L4_EXAMPLE
  510. {
  511. struct omap_overlay *ovl;
  512. ovl = kzalloc(sizeof(*ovl), GFP_KERNEL);
  513. BUG_ON(ovl == NULL);
  514. ovl->name = "l4";
  515. ovl->supported_modes = OMAP_DSS_COLOR_RGB24U;
  516. ovl->set_manager = &omap_dss_set_manager;
  517. ovl->unset_manager = &omap_dss_unset_manager;
  518. ovl->set_overlay_info = &dss_ovl_set_overlay_info;
  519. ovl->get_overlay_info = &dss_ovl_get_overlay_info;
  520. omap_dss_add_overlay(ovl);
  521. r = kobject_init_and_add(&ovl->kobj, &overlay_ktype,
  522. &pdev->dev.kobj, "overlayl4");
  523. if (r)
  524. DSSERR("failed to create sysfs file\n");
  525. l4_overlays[0] = ovl;
  526. }
  527. #endif
  528. }
  529. /* connect overlays to the new device, if not already connected. if force
  530. * selected, connect always. */
  531. void dss_recheck_connections(struct omap_dss_device *dssdev, bool force)
  532. {
  533. int i;
  534. struct omap_overlay_manager *lcd_mgr;
  535. struct omap_overlay_manager *tv_mgr;
  536. struct omap_overlay_manager *lcd2_mgr = NULL;
  537. struct omap_overlay_manager *mgr = NULL;
  538. lcd_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_LCD);
  539. tv_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_TV);
  540. if (dss_has_feature(FEAT_MGR_LCD2))
  541. lcd2_mgr = omap_dss_get_overlay_manager(OMAP_DSS_OVL_MGR_LCD2);
  542. if (dssdev->channel == OMAP_DSS_CHANNEL_LCD2) {
  543. if (!lcd2_mgr->device || force) {
  544. if (lcd2_mgr->device)
  545. lcd2_mgr->unset_device(lcd2_mgr);
  546. lcd2_mgr->set_device(lcd2_mgr, dssdev);
  547. mgr = lcd2_mgr;
  548. }
  549. } else if (dssdev->type != OMAP_DISPLAY_TYPE_VENC
  550. && dssdev->type != OMAP_DISPLAY_TYPE_HDMI) {
  551. if (!lcd_mgr->device || force) {
  552. if (lcd_mgr->device)
  553. lcd_mgr->unset_device(lcd_mgr);
  554. lcd_mgr->set_device(lcd_mgr, dssdev);
  555. mgr = lcd_mgr;
  556. }
  557. }
  558. if (dssdev->type == OMAP_DISPLAY_TYPE_VENC
  559. || dssdev->type == OMAP_DISPLAY_TYPE_HDMI) {
  560. if (!tv_mgr->device || force) {
  561. if (tv_mgr->device)
  562. tv_mgr->unset_device(tv_mgr);
  563. tv_mgr->set_device(tv_mgr, dssdev);
  564. mgr = tv_mgr;
  565. }
  566. }
  567. if (mgr) {
  568. dispc_runtime_get();
  569. for (i = 0; i < dss_feat_get_num_ovls(); i++) {
  570. struct omap_overlay *ovl;
  571. ovl = omap_dss_get_overlay(i);
  572. if (!ovl->manager || force) {
  573. if (ovl->manager)
  574. omap_dss_unset_manager(ovl);
  575. omap_dss_set_manager(ovl, mgr);
  576. }
  577. }
  578. dispc_runtime_put();
  579. }
  580. }
  581. void dss_uninit_overlays(struct platform_device *pdev)
  582. {
  583. struct omap_overlay *ovl;
  584. while (!list_empty(&overlay_list)) {
  585. ovl = list_first_entry(&overlay_list,
  586. struct omap_overlay, list);
  587. list_del(&ovl->list);
  588. kobject_del(&ovl->kobj);
  589. kobject_put(&ovl->kobj);
  590. kfree(ovl);
  591. }
  592. num_overlays = 0;
  593. }