27
27
#include "amdgpu.h"
28
28
#include "amdgpu_dm.h"
29
29
#include "dm_helpers.h"
30
+ #include <drm/drm_hdcp.h>
30
31
31
32
bool lp_write_i2c (void * handle , uint32_t address , const uint8_t * data , uint32_t size )
32
33
{
@@ -82,16 +83,19 @@ static void process_output(struct hdcp_workqueue *hdcp_work)
82
83
83
84
}
84
85
85
- void hdcp_add_display (struct hdcp_workqueue * hdcp_work , unsigned int link_index )
86
+ void hdcp_add_display (struct hdcp_workqueue * hdcp_work , unsigned int link_index , struct amdgpu_dm_connector * aconnector )
86
87
{
87
88
struct hdcp_workqueue * hdcp_w = & hdcp_work [link_index ];
88
89
struct mod_hdcp_display * display = & hdcp_work [link_index ].display ;
89
90
struct mod_hdcp_link * link = & hdcp_work [link_index ].link ;
90
91
91
92
mutex_lock (& hdcp_w -> mutex );
93
+ hdcp_w -> aconnector = aconnector ;
92
94
93
95
mod_hdcp_add_display (& hdcp_w -> hdcp , link , display , & hdcp_w -> output );
94
96
97
+ schedule_delayed_work (& hdcp_w -> property_validate_dwork , msecs_to_jiffies (DRM_HDCP_CHECK_PERIOD_MS ));
98
+
95
99
process_output (hdcp_w );
96
100
97
101
mutex_unlock (& hdcp_w -> mutex );
@@ -106,6 +110,9 @@ void hdcp_remove_display(struct hdcp_workqueue *hdcp_work, unsigned int link_ind
106
110
107
111
mod_hdcp_remove_display (& hdcp_w -> hdcp , display_index , & hdcp_w -> output );
108
112
113
+ cancel_delayed_work (& hdcp_w -> property_validate_dwork );
114
+ hdcp_w -> encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
115
+
109
116
process_output (hdcp_w );
110
117
111
118
mutex_unlock (& hdcp_w -> mutex );
@@ -120,6 +127,9 @@ void hdcp_reset_display(struct hdcp_workqueue *hdcp_work, unsigned int link_inde
120
127
121
128
mod_hdcp_reset_connection (& hdcp_w -> hdcp , & hdcp_w -> output );
122
129
130
+ cancel_delayed_work (& hdcp_w -> property_validate_dwork );
131
+ hdcp_w -> encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
132
+
123
133
process_output (hdcp_w );
124
134
125
135
mutex_unlock (& hdcp_w -> mutex );
@@ -155,7 +165,58 @@ static void event_callback(struct work_struct *work)
155
165
156
166
157
167
}
168
+ static void event_property_update (struct work_struct * work )
169
+ {
170
+
171
+ struct hdcp_workqueue * hdcp_work = container_of (work , struct hdcp_workqueue , property_update_work );
172
+ struct amdgpu_dm_connector * aconnector = hdcp_work -> aconnector ;
173
+ struct drm_device * dev = hdcp_work -> aconnector -> base .dev ;
174
+ long ret ;
175
+
176
+ drm_modeset_lock (& dev -> mode_config .connection_mutex , NULL );
177
+ mutex_lock (& hdcp_work -> mutex );
178
+
179
+
180
+ if (aconnector -> base .state -> commit ) {
181
+ ret = wait_for_completion_interruptible_timeout (& aconnector -> base .state -> commit -> hw_done , 10 * HZ );
182
+
183
+ if (ret == 0 ) {
184
+ DRM_ERROR ("HDCP state unknown! Setting it to DESIRED" );
185
+ hdcp_work -> encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
186
+ }
187
+ }
188
+
189
+ if (hdcp_work -> encryption_status == MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON )
190
+ drm_hdcp_update_content_protection (& aconnector -> base , DRM_MODE_CONTENT_PROTECTION_ENABLED );
191
+ else
192
+ drm_hdcp_update_content_protection (& aconnector -> base , DRM_MODE_CONTENT_PROTECTION_DESIRED );
193
+
194
+
195
+ mutex_unlock (& hdcp_work -> mutex );
196
+ drm_modeset_unlock (& dev -> mode_config .connection_mutex );
197
+ }
198
+
199
+ static void event_property_validate (struct work_struct * work )
200
+ {
201
+ struct hdcp_workqueue * hdcp_work =
202
+ container_of (to_delayed_work (work ), struct hdcp_workqueue , property_validate_dwork );
203
+ struct mod_hdcp_display_query query ;
204
+ struct amdgpu_dm_connector * aconnector = hdcp_work -> aconnector ;
205
+
206
+ mutex_lock (& hdcp_work -> mutex );
158
207
208
+ query .encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
209
+ mod_hdcp_query_display (& hdcp_work -> hdcp , aconnector -> base .index , & query );
210
+
211
+ if (query .encryption_status != hdcp_work -> encryption_status ) {
212
+ hdcp_work -> encryption_status = query .encryption_status ;
213
+ schedule_work (& hdcp_work -> property_update_work );
214
+ }
215
+
216
+ schedule_delayed_work (& hdcp_work -> property_validate_dwork , msecs_to_jiffies (DRM_HDCP_CHECK_PERIOD_MS ));
217
+
218
+ mutex_unlock (& hdcp_work -> mutex );
219
+ }
159
220
160
221
static void event_watchdog_timer (struct work_struct * work )
161
222
{
@@ -250,8 +311,10 @@ struct hdcp_workqueue *hdcp_create_workqueue(void *psp_context, struct cp_psp *c
250
311
mutex_init (& hdcp_work [i ].mutex );
251
312
252
313
INIT_WORK (& hdcp_work [i ].cpirq_work , event_cpirq );
314
+ INIT_WORK (& hdcp_work [i ].property_update_work , event_property_update );
253
315
INIT_DELAYED_WORK (& hdcp_work [i ].callback_dwork , event_callback );
254
316
INIT_DELAYED_WORK (& hdcp_work [i ].watchdog_timer_dwork , event_watchdog_timer );
317
+ INIT_DELAYED_WORK (& hdcp_work [i ].property_validate_dwork , event_property_validate );
255
318
256
319
hdcp_work [i ].hdcp .config .psp .handle = psp_context ;
257
320
hdcp_work [i ].hdcp .config .ddc .handle = dc_get_link_at_index (dc , i );
0 commit comments