forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/gpu/drm/omapdrm/dss/omapdss.h
....@@ -1,25 +1,13 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
34 * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
187 #ifndef __OMAP_DRM_DSS_H
198 #define __OMAP_DRM_DSS_H
209
2110 #include <linux/list.h>
22
-#include <linux/kobject.h>
2311 #include <linux/device.h>
2412 #include <linux/interrupt.h>
2513 #include <video/videomode.h>
....@@ -68,6 +56,7 @@
6856 struct snd_aes_iec958;
6957 struct snd_cea_861_aud_if;
7058 struct hdmi_avi_infoframe;
59
+struct drm_connector;
7160
7261 enum omap_display_type {
7362 OMAP_DISPLAY_TYPE_NONE = 0,
....@@ -296,117 +285,7 @@
296285 u8 pre_mult_alpha;
297286 };
298287
299
-struct omapdss_dpi_ops {
300
- int (*connect)(struct omap_dss_device *dssdev,
301
- struct omap_dss_device *dst);
302
- void (*disconnect)(struct omap_dss_device *dssdev,
303
- struct omap_dss_device *dst);
304
-
305
- int (*enable)(struct omap_dss_device *dssdev);
306
- void (*disable)(struct omap_dss_device *dssdev);
307
-
308
- int (*check_timings)(struct omap_dss_device *dssdev,
309
- struct videomode *vm);
310
- void (*set_timings)(struct omap_dss_device *dssdev,
311
- struct videomode *vm);
312
- void (*get_timings)(struct omap_dss_device *dssdev,
313
- struct videomode *vm);
314
-};
315
-
316
-struct omapdss_sdi_ops {
317
- int (*connect)(struct omap_dss_device *dssdev,
318
- struct omap_dss_device *dst);
319
- void (*disconnect)(struct omap_dss_device *dssdev,
320
- struct omap_dss_device *dst);
321
-
322
- int (*enable)(struct omap_dss_device *dssdev);
323
- void (*disable)(struct omap_dss_device *dssdev);
324
-
325
- int (*check_timings)(struct omap_dss_device *dssdev,
326
- struct videomode *vm);
327
- void (*set_timings)(struct omap_dss_device *dssdev,
328
- struct videomode *vm);
329
- void (*get_timings)(struct omap_dss_device *dssdev,
330
- struct videomode *vm);
331
-};
332
-
333
-struct omapdss_dvi_ops {
334
- int (*connect)(struct omap_dss_device *dssdev,
335
- struct omap_dss_device *dst);
336
- void (*disconnect)(struct omap_dss_device *dssdev,
337
- struct omap_dss_device *dst);
338
-
339
- int (*enable)(struct omap_dss_device *dssdev);
340
- void (*disable)(struct omap_dss_device *dssdev);
341
-
342
- int (*check_timings)(struct omap_dss_device *dssdev,
343
- struct videomode *vm);
344
- void (*set_timings)(struct omap_dss_device *dssdev,
345
- struct videomode *vm);
346
- void (*get_timings)(struct omap_dss_device *dssdev,
347
- struct videomode *vm);
348
-};
349
-
350
-struct omapdss_atv_ops {
351
- int (*connect)(struct omap_dss_device *dssdev,
352
- struct omap_dss_device *dst);
353
- void (*disconnect)(struct omap_dss_device *dssdev,
354
- struct omap_dss_device *dst);
355
-
356
- int (*enable)(struct omap_dss_device *dssdev);
357
- void (*disable)(struct omap_dss_device *dssdev);
358
-
359
- int (*check_timings)(struct omap_dss_device *dssdev,
360
- struct videomode *vm);
361
- void (*set_timings)(struct omap_dss_device *dssdev,
362
- struct videomode *vm);
363
- void (*get_timings)(struct omap_dss_device *dssdev,
364
- struct videomode *vm);
365
-
366
- int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
367
- u32 (*get_wss)(struct omap_dss_device *dssdev);
368
-};
369
-
370
-struct omapdss_hdmi_ops {
371
- int (*connect)(struct omap_dss_device *dssdev,
372
- struct omap_dss_device *dst);
373
- void (*disconnect)(struct omap_dss_device *dssdev,
374
- struct omap_dss_device *dst);
375
-
376
- int (*enable)(struct omap_dss_device *dssdev);
377
- void (*disable)(struct omap_dss_device *dssdev);
378
-
379
- int (*check_timings)(struct omap_dss_device *dssdev,
380
- struct videomode *vm);
381
- void (*set_timings)(struct omap_dss_device *dssdev,
382
- struct videomode *vm);
383
- void (*get_timings)(struct omap_dss_device *dssdev,
384
- struct videomode *vm);
385
-
386
- int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
387
- void (*lost_hotplug)(struct omap_dss_device *dssdev);
388
- bool (*detect)(struct omap_dss_device *dssdev);
389
-
390
- int (*register_hpd_cb)(struct omap_dss_device *dssdev,
391
- void (*cb)(void *cb_data,
392
- enum drm_connector_status status),
393
- void *cb_data);
394
- void (*unregister_hpd_cb)(struct omap_dss_device *dssdev);
395
- void (*enable_hpd)(struct omap_dss_device *dssdev);
396
- void (*disable_hpd)(struct omap_dss_device *dssdev);
397
-
398
- int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
399
- int (*set_infoframe)(struct omap_dss_device *dssdev,
400
- const struct hdmi_avi_infoframe *avi);
401
-};
402
-
403288 struct omapdss_dsi_ops {
404
- int (*connect)(struct omap_dss_device *dssdev,
405
- struct omap_dss_device *dst);
406
- void (*disconnect)(struct omap_dss_device *dssdev,
407
- struct omap_dss_device *dst);
408
-
409
- int (*enable)(struct omap_dss_device *dssdev);
410289 void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
411290 bool enter_ulps);
412291
....@@ -457,78 +336,82 @@
457336 int channel, u16 plen);
458337 };
459338
339
+struct omap_dss_device_ops {
340
+ int (*connect)(struct omap_dss_device *dssdev,
341
+ struct omap_dss_device *dst);
342
+ void (*disconnect)(struct omap_dss_device *dssdev,
343
+ struct omap_dss_device *dst);
344
+
345
+ void (*enable)(struct omap_dss_device *dssdev);
346
+ void (*disable)(struct omap_dss_device *dssdev);
347
+
348
+ int (*check_timings)(struct omap_dss_device *dssdev,
349
+ struct drm_display_mode *mode);
350
+
351
+ int (*get_modes)(struct omap_dss_device *dssdev,
352
+ struct drm_connector *connector);
353
+
354
+ const struct omapdss_dsi_ops dsi;
355
+};
356
+
357
+/**
358
+ * enum omap_dss_device_ops_flag - Indicates which device ops are supported
359
+ * @OMAP_DSS_DEVICE_OP_MODES: The device supports reading modes
360
+ */
361
+enum omap_dss_device_ops_flag {
362
+ OMAP_DSS_DEVICE_OP_MODES = BIT(3),
363
+};
364
+
460365 struct omap_dss_device {
461
- struct kobject kobj;
462366 struct device *dev;
463367
464368 struct module *owner;
465369
466
- struct list_head panel_list;
370
+ struct dss_device *dss;
371
+ struct omap_dss_device *next;
372
+ struct drm_bridge *bridge;
373
+ struct drm_bridge *next_bridge;
374
+ struct drm_panel *panel;
467375
468
- /* alias in the form of "display%d" */
469
- char alias[16];
376
+ struct list_head list;
470377
378
+ /*
379
+ * DSS type that this device generates (for DSS internal devices) or
380
+ * requires (for external encoders, connectors and panels). Must be a
381
+ * non-zero (different than OMAP_DISPLAY_TYPE_NONE) value.
382
+ */
471383 enum omap_display_type type;
472
- enum omap_display_type output_type;
473384
474
- struct {
475
- struct videomode vm;
476
-
477
- enum omap_dss_dsi_pixel_format dsi_pix_fmt;
478
- enum omap_dss_dsi_mode dsi_mode;
479
- } panel;
385
+ /*
386
+ * True if the device is a display (panel or connector) at the end of
387
+ * the pipeline, false otherwise.
388
+ */
389
+ bool display;
480390
481391 const char *name;
482392
483
- struct omap_dss_driver *driver;
484
-
485
- union {
486
- const struct omapdss_dpi_ops *dpi;
487
- const struct omapdss_sdi_ops *sdi;
488
- const struct omapdss_dvi_ops *dvi;
489
- const struct omapdss_hdmi_ops *hdmi;
490
- const struct omapdss_atv_ops *atv;
491
- const struct omapdss_dsi_ops *dsi;
492
- } ops;
493
-
494
- /* helper variable for driver suspend/resume */
495
- bool activate_after_resume;
393
+ const struct omap_dss_driver *driver;
394
+ const struct omap_dss_device_ops *ops;
395
+ unsigned long ops_flags;
396
+ u32 bus_flags;
496397
497398 enum omap_display_caps caps;
498
-
499
- struct omap_dss_device *src;
500399
501400 enum omap_dss_display_state state;
502401
503402 /* OMAP DSS output specific fields */
504403
505
- struct list_head list;
506
-
507404 /* DISPC channel for this output */
508405 enum omap_channel dispc_channel;
509
- bool dispc_channel_connected;
510406
511407 /* output instance */
512408 enum omap_dss_output_id id;
513409
514
- /* the port number in the DT node */
515
- int port_num;
516
-
517
- /* dynamic fields */
518
- struct omap_dss_device *dst;
410
+ /* port number in DT */
411
+ unsigned int of_port;
519412 };
520413
521414 struct omap_dss_driver {
522
- int (*probe)(struct omap_dss_device *);
523
- void (*remove)(struct omap_dss_device *);
524
-
525
- int (*connect)(struct omap_dss_device *dssdev);
526
- void (*disconnect)(struct omap_dss_device *dssdev);
527
-
528
- int (*enable)(struct omap_dss_device *display);
529
- void (*disable)(struct omap_dss_device *display);
530
- int (*run_test)(struct omap_dss_device *display, int test);
531
-
532415 int (*update)(struct omap_dss_device *dssdev,
533416 u16 x, u16 y, u16 w, u16 h);
534417 int (*sync)(struct omap_dss_device *dssdev);
....@@ -536,42 +419,9 @@
536419 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
537420 int (*get_te)(struct omap_dss_device *dssdev);
538421
539
- u8 (*get_rotate)(struct omap_dss_device *dssdev);
540
- int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
541
-
542
- bool (*get_mirror)(struct omap_dss_device *dssdev);
543
- int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
544
-
545422 int (*memory_read)(struct omap_dss_device *dssdev,
546423 void *buf, size_t size,
547424 u16 x, u16 y, u16 w, u16 h);
548
-
549
- int (*check_timings)(struct omap_dss_device *dssdev,
550
- struct videomode *vm);
551
- void (*set_timings)(struct omap_dss_device *dssdev,
552
- struct videomode *vm);
553
- void (*get_timings)(struct omap_dss_device *dssdev,
554
- struct videomode *vm);
555
- void (*get_size)(struct omap_dss_device *dssdev,
556
- unsigned int *width, unsigned int *height);
557
-
558
- int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
559
- u32 (*get_wss)(struct omap_dss_device *dssdev);
560
-
561
- int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
562
- bool (*detect)(struct omap_dss_device *dssdev);
563
-
564
- int (*register_hpd_cb)(struct omap_dss_device *dssdev,
565
- void (*cb)(void *cb_data,
566
- enum drm_connector_status status),
567
- void *cb_data);
568
- void (*unregister_hpd_cb)(struct omap_dss_device *dssdev);
569
- void (*enable_hpd)(struct omap_dss_device *dssdev);
570
- void (*disable_hpd)(struct omap_dss_device *dssdev);
571
-
572
- int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
573
- int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev,
574
- const struct hdmi_avi_infoframe *avi);
575425 };
576426
577427 struct dss_device *omapdss_get_dss(void);
....@@ -581,27 +431,33 @@
581431 return !!omapdss_get_dss();
582432 }
583433
584
-int omapdss_register_display(struct omap_dss_device *dssdev);
585
-void omapdss_unregister_display(struct omap_dss_device *dssdev);
434
+void omapdss_display_init(struct omap_dss_device *dssdev);
435
+int omapdss_display_get_modes(struct drm_connector *connector,
436
+ const struct videomode *vm);
586437
587
-struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
588
-void omap_dss_put_device(struct omap_dss_device *dssdev);
589
-#define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
590
-struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
438
+void omapdss_device_register(struct omap_dss_device *dssdev);
439
+void omapdss_device_unregister(struct omap_dss_device *dssdev);
440
+struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev);
441
+void omapdss_device_put(struct omap_dss_device *dssdev);
442
+struct omap_dss_device *omapdss_find_device_by_node(struct device_node *node);
443
+int omapdss_device_connect(struct dss_device *dss,
444
+ struct omap_dss_device *src,
445
+ struct omap_dss_device *dst);
446
+void omapdss_device_disconnect(struct omap_dss_device *src,
447
+ struct omap_dss_device *dst);
448
+void omapdss_device_enable(struct omap_dss_device *dssdev);
449
+void omapdss_device_disable(struct omap_dss_device *dssdev);
591450
592451 int omap_dss_get_num_overlay_managers(void);
593452
594453 int omap_dss_get_num_overlays(void);
595454
596
-int omapdss_register_output(struct omap_dss_device *output);
597
-void omapdss_unregister_output(struct omap_dss_device *output);
598
-struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
599
-struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port);
600
-int omapdss_output_set_device(struct omap_dss_device *out,
601
- struct omap_dss_device *dssdev);
602
-int omapdss_output_unset_device(struct omap_dss_device *out);
603
-
604
-struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
455
+#define for_each_dss_output(d) \
456
+ while ((d = omapdss_device_next_output(d)) != NULL)
457
+struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from);
458
+int omapdss_device_init_output(struct omap_dss_device *out,
459
+ struct drm_bridge *local_bridge);
460
+void omapdss_device_cleanup_output(struct omap_dss_device *out);
605461
606462 typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
607463 int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
....@@ -610,21 +466,10 @@
610466 int omapdss_compat_init(void);
611467 void omapdss_compat_uninit(void);
612468
613
-static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
614
-{
615
- return dssdev->src;
616
-}
617
-
618469 static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
619470 {
620471 return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
621472 }
622
-
623
-struct omap_dss_device *
624
-omapdss_of_find_source_for_first_ep(struct device_node *node);
625
-
626
-struct device_node *dss_of_port_get_parent_device(struct device_node *port);
627
-u32 dss_of_port_get_port_number(struct device_node *port);
628473
629474 enum dss_writeback_channel {
630475 DSS_WB_LCD1_MGR = 0,
....@@ -638,13 +483,6 @@
638483 };
639484
640485 struct dss_mgr_ops {
641
- int (*connect)(struct omap_drm_private *priv,
642
- enum omap_channel channel,
643
- struct omap_dss_device *dst);
644
- void (*disconnect)(struct omap_drm_private *priv,
645
- enum omap_channel channel,
646
- struct omap_dss_device *dst);
647
-
648486 void (*start_update)(struct omap_drm_private *priv,
649487 enum omap_channel channel);
650488 int (*enable)(struct omap_drm_private *priv,
....@@ -665,14 +503,11 @@
665503 void (*handler)(void *), void *data);
666504 };
667505
668
-int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops,
506
+int dss_install_mgr_ops(struct dss_device *dss,
507
+ const struct dss_mgr_ops *mgr_ops,
669508 struct omap_drm_private *priv);
670
-void dss_uninstall_mgr_ops(void);
509
+void dss_uninstall_mgr_ops(struct dss_device *dss);
671510
672
-int dss_mgr_connect(struct omap_dss_device *dssdev,
673
- struct omap_dss_device *dst);
674
-void dss_mgr_disconnect(struct omap_dss_device *dssdev,
675
- struct omap_dss_device *dst);
676511 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
677512 const struct videomode *vm);
678513 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
....@@ -720,13 +555,14 @@
720555 void (*mgr_set_lcd_config)(struct dispc_device *dispc,
721556 enum omap_channel channel,
722557 const struct dss_lcd_mgr_config *config);
558
+ int (*mgr_check_timings)(struct dispc_device *dispc,
559
+ enum omap_channel channel,
560
+ const struct videomode *vm);
723561 void (*mgr_set_timings)(struct dispc_device *dispc,
724562 enum omap_channel channel,
725563 const struct videomode *vm);
726564 void (*mgr_setup)(struct dispc_device *dispc, enum omap_channel channel,
727565 const struct omap_overlay_manager_info *info);
728
- enum omap_dss_output_id (*mgr_get_supported_outputs)(
729
- struct dispc_device *dispc, enum omap_channel channel);
730566 u32 (*mgr_gamma_size)(struct dispc_device *dispc,
731567 enum omap_channel channel);
732568 void (*mgr_set_gamma)(struct dispc_device *dispc,
....@@ -756,9 +592,6 @@
756592
757593 struct dispc_device *dispc_get_dispc(struct dss_device *dss);
758594 const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
759
-
760
-bool omapdss_component_is_display(struct device_node *node);
761
-bool omapdss_component_is_output(struct device_node *node);
762595
763596 bool omapdss_stack_is_ready(void);
764597 void omapdss_gather_components(struct device *dev);