@@ -63,7 +63,6 @@ struct rcar_lvds {
63
63
struct drm_bridge bridge ;
64
64
65
65
struct drm_bridge * next_bridge ;
66
- struct drm_connector connector ;
67
66
struct drm_panel * panel ;
68
67
69
68
void __iomem * mmio ;
@@ -80,73 +79,11 @@ struct rcar_lvds {
80
79
#define bridge_to_rcar_lvds (b ) \
81
80
container_of(b, struct rcar_lvds, bridge)
82
81
83
- #define connector_to_rcar_lvds (c ) \
84
- container_of(c, struct rcar_lvds, connector)
85
-
86
82
static void rcar_lvds_write (struct rcar_lvds * lvds , u32 reg , u32 data )
87
83
{
88
84
iowrite32 (data , lvds -> mmio + reg );
89
85
}
90
86
91
- /* -----------------------------------------------------------------------------
92
- * Connector & Panel
93
- */
94
-
95
- static int rcar_lvds_connector_get_modes (struct drm_connector * connector )
96
- {
97
- struct rcar_lvds * lvds = connector_to_rcar_lvds (connector );
98
-
99
- return drm_panel_get_modes (lvds -> panel , connector );
100
- }
101
-
102
- static int rcar_lvds_connector_atomic_check (struct drm_connector * connector ,
103
- struct drm_atomic_state * state )
104
- {
105
- struct rcar_lvds * lvds = connector_to_rcar_lvds (connector );
106
- const struct drm_display_mode * panel_mode ;
107
- struct drm_connector_state * conn_state ;
108
- struct drm_crtc_state * crtc_state ;
109
-
110
- conn_state = drm_atomic_get_new_connector_state (state , connector );
111
- if (!conn_state -> crtc )
112
- return 0 ;
113
-
114
- if (list_empty (& connector -> modes )) {
115
- dev_dbg (lvds -> dev , "connector: empty modes list\n" );
116
- return - EINVAL ;
117
- }
118
-
119
- panel_mode = list_first_entry (& connector -> modes ,
120
- struct drm_display_mode , head );
121
-
122
- /* We're not allowed to modify the resolution. */
123
- crtc_state = drm_atomic_get_crtc_state (state , conn_state -> crtc );
124
- if (IS_ERR (crtc_state ))
125
- return PTR_ERR (crtc_state );
126
-
127
- if (crtc_state -> mode .hdisplay != panel_mode -> hdisplay ||
128
- crtc_state -> mode .vdisplay != panel_mode -> vdisplay )
129
- return - EINVAL ;
130
-
131
- /* The flat panel mode is fixed, just copy it to the adjusted mode. */
132
- drm_mode_copy (& crtc_state -> adjusted_mode , panel_mode );
133
-
134
- return 0 ;
135
- }
136
-
137
- static const struct drm_connector_helper_funcs rcar_lvds_conn_helper_funcs = {
138
- .get_modes = rcar_lvds_connector_get_modes ,
139
- .atomic_check = rcar_lvds_connector_atomic_check ,
140
- };
141
-
142
- static const struct drm_connector_funcs rcar_lvds_conn_funcs = {
143
- .reset = drm_atomic_helper_connector_reset ,
144
- .fill_modes = drm_helper_probe_single_connector_modes ,
145
- .destroy = drm_connector_cleanup ,
146
- .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state ,
147
- .atomic_destroy_state = drm_atomic_helper_connector_destroy_state ,
148
- };
149
-
150
87
/* -----------------------------------------------------------------------------
151
88
* PLL Setup
152
89
*/
@@ -583,11 +520,6 @@ static void __rcar_lvds_atomic_enable(struct drm_bridge *bridge,
583
520
/* Turn the output on. */
584
521
lvdcr0 |= LVDCR0_LVRES ;
585
522
rcar_lvds_write (lvds , LVDCR0 , lvdcr0 );
586
-
587
- if (lvds -> panel ) {
588
- drm_panel_prepare (lvds -> panel );
589
- drm_panel_enable (lvds -> panel );
590
- }
591
523
}
592
524
593
525
static void rcar_lvds_atomic_enable (struct drm_bridge * bridge ,
@@ -609,11 +541,6 @@ static void rcar_lvds_atomic_disable(struct drm_bridge *bridge,
609
541
{
610
542
struct rcar_lvds * lvds = bridge_to_rcar_lvds (bridge );
611
543
612
- if (lvds -> panel ) {
613
- drm_panel_disable (lvds -> panel );
614
- drm_panel_unprepare (lvds -> panel );
615
- }
616
-
617
544
rcar_lvds_write (lvds , LVDCR0 , 0 );
618
545
rcar_lvds_write (lvds , LVDCR1 , 0 );
619
546
rcar_lvds_write (lvds , LVDPLLCR , 0 );
@@ -648,45 +575,13 @@ static int rcar_lvds_attach(struct drm_bridge *bridge,
648
575
enum drm_bridge_attach_flags flags )
649
576
{
650
577
struct rcar_lvds * lvds = bridge_to_rcar_lvds (bridge );
651
- struct drm_connector * connector = & lvds -> connector ;
652
- struct drm_encoder * encoder = bridge -> encoder ;
653
- int ret ;
654
-
655
- /* If we have a next bridge just attach it. */
656
- if (lvds -> next_bridge )
657
- return drm_bridge_attach (bridge -> encoder , lvds -> next_bridge ,
658
- bridge , flags );
659
-
660
- if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ) {
661
- DRM_ERROR ("Fix bridge driver to make connector optional!" );
662
- return - EINVAL ;
663
- }
664
-
665
- /* Otherwise if we have a panel, create a connector. */
666
- if (!lvds -> panel )
667
- return 0 ;
668
-
669
- ret = drm_connector_init (bridge -> dev , connector , & rcar_lvds_conn_funcs ,
670
- DRM_MODE_CONNECTOR_LVDS );
671
- if (ret < 0 )
672
- return ret ;
673
-
674
- drm_connector_helper_add (connector , & rcar_lvds_conn_helper_funcs );
675
-
676
- ret = drm_connector_attach_encoder (connector , encoder );
677
- if (ret < 0 )
678
- return ret ;
679
-
680
- return 0 ;
681
- }
682
578
683
- static void rcar_lvds_detach ( struct drm_bridge * bridge )
684
- {
579
+ return drm_bridge_attach ( bridge -> encoder , lvds -> next_bridge , bridge ,
580
+ flags );
685
581
}
686
582
687
583
static const struct drm_bridge_funcs rcar_lvds_bridge_ops = {
688
584
.attach = rcar_lvds_attach ,
689
- .detach = rcar_lvds_detach ,
690
585
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state ,
691
586
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state ,
692
587
.atomic_reset = drm_atomic_helper_bridge_reset ,
@@ -759,7 +654,7 @@ static int rcar_lvds_parse_dt_companion(struct rcar_lvds *lvds)
759
654
* that we are expected to generate even pixels from the primary
760
655
* encoder, and odd pixels from the companion encoder.
761
656
*/
762
- if (lvds -> next_bridge && lvds -> next_bridge -> timings &&
657
+ if (lvds -> next_bridge -> timings &&
763
658
lvds -> next_bridge -> timings -> dual_link )
764
659
lvds -> link_type = RCAR_LVDS_DUAL_LINK_EVEN_ODD_PIXELS ;
765
660
else
@@ -811,6 +706,15 @@ static int rcar_lvds_parse_dt(struct rcar_lvds *lvds)
811
706
if (ret )
812
707
goto done ;
813
708
709
+ if (lvds -> panel ) {
710
+ lvds -> next_bridge = devm_drm_panel_bridge_add (lvds -> dev ,
711
+ lvds -> panel );
712
+ if (IS_ERR_OR_NULL (lvds -> next_bridge )) {
713
+ ret = - EINVAL ;
714
+ goto done ;
715
+ }
716
+ }
717
+
814
718
if (lvds -> info -> quirks & RCAR_LVDS_QUIRK_DUAL_LINK )
815
719
ret = rcar_lvds_parse_dt_companion (lvds );
816
720
0 commit comments