aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/omap2/dss/core.c291
-rw-r--r--drivers/video/omap2/dss/dss.h9
2 files changed, 4 insertions, 296 deletions
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 71e6a77ec687..415b5d6385fc 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -248,235 +248,6 @@ static struct platform_driver omap_dss_driver = {
248 }, 248 },
249}; 249};
250 250
251/* BUS */
252static int dss_bus_match(struct device *dev, struct device_driver *driver)
253{
254 struct omap_dss_device *dssdev = to_dss_device(dev);
255
256 DSSDBG("bus_match. dev %s/%s, drv %s\n",
257 dev_name(dev), dssdev->driver_name, driver->name);
258
259 return strcmp(dssdev->driver_name, driver->name) == 0;
260}
261
262static struct bus_type dss_bus_type = {
263 .name = "omapdss",
264 .match = dss_bus_match,
265};
266
267static void dss_bus_release(struct device *dev)
268{
269 DSSDBG("bus_release\n");
270}
271
272static struct device dss_bus = {
273 .release = dss_bus_release,
274};
275
276struct bus_type *dss_get_bus(void)
277{
278 return &dss_bus_type;
279}
280
281/* DRIVER */
282static int dss_driver_probe(struct device *dev)
283{
284 int r;
285 struct omap_dss_driver *dssdrv = to_dss_driver(dev->driver);
286 struct omap_dss_device *dssdev = to_dss_device(dev);
287
288 DSSDBG("driver_probe: dev %s/%s, drv %s\n",
289 dev_name(dev), dssdev->driver_name,
290 dssdrv->driver.name);
291
292 r = dssdrv->probe(dssdev);
293
294 if (r) {
295 DSSERR("driver probe failed: %d\n", r);
296 return r;
297 }
298
299 DSSDBG("probe done for device %s\n", dev_name(dev));
300
301 dssdev->driver = dssdrv;
302
303 return 0;
304}
305
306static int dss_driver_remove(struct device *dev)
307{
308 struct omap_dss_driver *dssdrv = to_dss_driver(dev->driver);
309 struct omap_dss_device *dssdev = to_dss_device(dev);
310
311 DSSDBG("driver_remove: dev %s/%s\n", dev_name(dev),
312 dssdev->driver_name);
313
314 dssdrv->remove(dssdev);
315
316 dssdev->driver = NULL;
317
318 return 0;
319}
320
321static int omapdss_default_connect(struct omap_dss_device *dssdev)
322{
323 struct omap_dss_device *out;
324 struct omap_overlay_manager *mgr;
325 int r;
326
327 out = dssdev->output;
328
329 if (out == NULL)
330 return -ENODEV;
331
332 mgr = omap_dss_get_overlay_manager(out->dispc_channel);
333 if (!mgr)
334 return -ENODEV;
335
336 r = dss_mgr_connect(mgr, out);
337 if (r)
338 return r;
339
340 return 0;
341}
342
343static void omapdss_default_disconnect(struct omap_dss_device *dssdev)
344{
345 struct omap_dss_device *out;
346 struct omap_overlay_manager *mgr;
347
348 out = dssdev->output;
349
350 if (out == NULL)
351 return;
352
353 mgr = out->manager;
354
355 if (mgr == NULL)
356 return;
357
358 dss_mgr_disconnect(mgr, out);
359}
360
361int omap_dss_register_driver(struct omap_dss_driver *dssdriver)
362{
363 dssdriver->driver.bus = &dss_bus_type;
364 dssdriver->driver.probe = dss_driver_probe;
365 dssdriver->driver.remove = dss_driver_remove;
366
367 if (dssdriver->get_resolution == NULL)
368 dssdriver->get_resolution = omapdss_default_get_resolution;
369 if (dssdriver->get_recommended_bpp == NULL)
370 dssdriver->get_recommended_bpp =
371 omapdss_default_get_recommended_bpp;
372 if (dssdriver->get_timings == NULL)
373 dssdriver->get_timings = omapdss_default_get_timings;
374 if (dssdriver->connect == NULL)
375 dssdriver->connect = omapdss_default_connect;
376 if (dssdriver->disconnect == NULL)
377 dssdriver->disconnect = omapdss_default_disconnect;
378
379 return driver_register(&dssdriver->driver);
380}
381EXPORT_SYMBOL(omap_dss_register_driver);
382
383void omap_dss_unregister_driver(struct omap_dss_driver *dssdriver)
384{
385 driver_unregister(&dssdriver->driver);
386}
387EXPORT_SYMBOL(omap_dss_unregister_driver);
388
389/* DEVICE */
390
391static void omap_dss_dev_release(struct device *dev)
392{
393 struct omap_dss_device *dssdev = to_dss_device(dev);
394 kfree(dssdev);
395}
396
397static int disp_num_counter;
398
399struct omap_dss_device *dss_alloc_and_init_device(struct device *parent)
400{
401 struct omap_dss_device *dssdev;
402
403 dssdev = kzalloc(sizeof(*dssdev), GFP_KERNEL);
404 if (!dssdev)
405 return NULL;
406
407 dssdev->old_dev.bus = &dss_bus_type;
408 dssdev->old_dev.parent = parent;
409 dssdev->old_dev.release = omap_dss_dev_release;
410 dev_set_name(&dssdev->old_dev, "display%d", disp_num_counter++);
411
412 device_initialize(&dssdev->old_dev);
413
414 return dssdev;
415}
416
417int dss_add_device(struct omap_dss_device *dssdev)
418{
419 dssdev->dev = &dssdev->old_dev;
420
421 omapdss_register_display(dssdev);
422 return device_add(&dssdev->old_dev);
423}
424
425void dss_put_device(struct omap_dss_device *dssdev)
426{
427 put_device(&dssdev->old_dev);
428}
429
430void dss_unregister_device(struct omap_dss_device *dssdev)
431{
432 device_unregister(&dssdev->old_dev);
433 omapdss_unregister_display(dssdev);
434}
435
436static int dss_unregister_dss_dev(struct device *dev, void *data)
437{
438 struct omap_dss_device *dssdev = to_dss_device(dev);
439 dss_unregister_device(dssdev);
440 return 0;
441}
442
443void dss_unregister_child_devices(struct device *parent)
444{
445 device_for_each_child(parent, NULL, dss_unregister_dss_dev);
446}
447
448void dss_copy_device_pdata(struct omap_dss_device *dst,
449 const struct omap_dss_device *src)
450{
451 u8 *d = (u8 *)dst;
452 u8 *s = (u8 *)src;
453 size_t dsize = sizeof(struct device);
454
455 memcpy(d + dsize, s + dsize, sizeof(struct omap_dss_device) - dsize);
456}
457
458/* BUS */
459static int __init omap_dss_bus_register(void)
460{
461 int r;
462
463 r = bus_register(&dss_bus_type);
464 if (r) {
465 DSSERR("bus register failed\n");
466 return r;
467 }
468
469 dev_set_name(&dss_bus, "omapdss");
470 r = device_register(&dss_bus);
471 if (r) {
472 DSSERR("bus driver register failed\n");
473 bus_unregister(&dss_bus_type);
474 return r;
475 }
476
477 return 0;
478}
479
480/* INIT */ 251/* INIT */
481static int (*dss_output_drv_reg_funcs[])(void) __initdata = { 252static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
482#ifdef CONFIG_OMAP2_DSS_DSI 253#ifdef CONFIG_OMAP2_DSS_DSI
@@ -522,7 +293,7 @@ static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
522 293
523static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)]; 294static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)];
524 295
525static int __init omap_dss_register_drivers(void) 296static int __init omap_dss_init(void)
526{ 297{
527 int r; 298 int r;
528 int i; 299 int i;
@@ -553,6 +324,8 @@ static int __init omap_dss_register_drivers(void)
553 dss_output_drv_loaded[i] = true; 324 dss_output_drv_loaded[i] = true;
554 } 325 }
555 326
327 dss_initialized = true;
328
556 return 0; 329 return 0;
557 330
558err_dispc: 331err_dispc:
@@ -563,7 +336,7 @@ err_dss:
563 return r; 336 return r;
564} 337}
565 338
566static void __exit omap_dss_unregister_drivers(void) 339static void __exit omap_dss_exit(void)
567{ 340{
568 int i; 341 int i;
569 342
@@ -578,64 +351,8 @@ static void __exit omap_dss_unregister_drivers(void)
578 platform_driver_unregister(&omap_dss_driver); 351 platform_driver_unregister(&omap_dss_driver);
579} 352}
580 353
581#ifdef CONFIG_OMAP2_DSS_MODULE
582static void omap_dss_bus_unregister(void)
583{
584 device_unregister(&dss_bus);
585
586 bus_unregister(&dss_bus_type);
587}
588
589static int __init omap_dss_init(void)
590{
591 int r;
592
593 r = omap_dss_bus_register();
594 if (r)
595 return r;
596
597 r = omap_dss_register_drivers();
598 if (r) {
599 omap_dss_bus_unregister();
600 return r;
601 }
602
603 dss_initialized = true;
604
605 return 0;
606}
607
608static void __exit omap_dss_exit(void)
609{
610 omap_dss_unregister_drivers();
611
612 omap_dss_bus_unregister();
613}
614
615module_init(omap_dss_init); 354module_init(omap_dss_init);
616module_exit(omap_dss_exit); 355module_exit(omap_dss_exit);
617#else
618static int __init omap_dss_init(void)
619{
620 return omap_dss_bus_register();
621}
622
623static int __init omap_dss_init2(void)
624{
625 int r;
626
627 r = omap_dss_register_drivers();
628 if (r)
629 return r;
630
631 dss_initialized = true;
632
633 return 0;
634}
635
636core_initcall(omap_dss_init);
637device_initcall(omap_dss_init2);
638#endif
639 356
640MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>"); 357MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
641MODULE_DESCRIPTION("OMAP2/3 Display Subsystem"); 358MODULE_DESCRIPTION("OMAP2/3 Display Subsystem");
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 68dd27f21a25..e172531d196b 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -163,20 +163,11 @@ struct platform_device;
163 163
164/* core */ 164/* core */
165struct platform_device *dss_get_core_pdev(void); 165struct platform_device *dss_get_core_pdev(void);
166struct bus_type *dss_get_bus(void);
167int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask); 166int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask);
168void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask); 167void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask);
169int dss_set_min_bus_tput(struct device *dev, unsigned long tput); 168int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
170int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); 169int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
171 170
172struct omap_dss_device *dss_alloc_and_init_device(struct device *parent);
173int dss_add_device(struct omap_dss_device *dssdev);
174void dss_unregister_device(struct omap_dss_device *dssdev);
175void dss_unregister_child_devices(struct device *parent);
176void dss_put_device(struct omap_dss_device *dssdev);
177void dss_copy_device_pdata(struct omap_dss_device *dst,
178 const struct omap_dss_device *src);
179
180/* display */ 171/* display */
181int dss_suspend_all_devices(void); 172int dss_suspend_all_devices(void);
182int dss_resume_all_devices(void); 173int dss_resume_all_devices(void);