overlay.c 17 KB

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