@@ -170,9 +170,10 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
170
170
struct mod_hdcp_display * display = & hdcp_work [link_index ].display ;
171
171
struct mod_hdcp_link * link = & hdcp_work [link_index ].link ;
172
172
struct mod_hdcp_display_query query ;
173
+ unsigned int conn_index = aconnector -> base .index ;
173
174
174
175
mutex_lock (& hdcp_w -> mutex );
175
- hdcp_w -> aconnector = aconnector ;
176
+ hdcp_w -> aconnector [ conn_index ] = aconnector ;
176
177
177
178
query .display = NULL ;
178
179
mod_hdcp_query_display (& hdcp_w -> hdcp , aconnector -> base .index , & query );
@@ -204,7 +205,7 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
204
205
msecs_to_jiffies (DRM_HDCP_CHECK_PERIOD_MS ));
205
206
} else {
206
207
display -> adjust .disable = MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION ;
207
- hdcp_w -> encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
208
+ hdcp_w -> encryption_status [ conn_index ] = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
208
209
cancel_delayed_work (& hdcp_w -> property_validate_dwork );
209
210
}
210
211
@@ -223,9 +224,10 @@ static void hdcp_remove_display(struct hdcp_workqueue *hdcp_work,
223
224
{
224
225
struct hdcp_workqueue * hdcp_w = & hdcp_work [link_index ];
225
226
struct drm_connector_state * conn_state = aconnector -> base .state ;
227
+ unsigned int conn_index = aconnector -> base .index ;
226
228
227
229
mutex_lock (& hdcp_w -> mutex );
228
- hdcp_w -> aconnector = aconnector ;
230
+ hdcp_w -> aconnector [ conn_index ] = aconnector ;
229
231
230
232
/* the removal of display will invoke auth reset -> hdcp destroy and
231
233
* we'd expect the Content Protection (CP) property changed back to
@@ -247,13 +249,18 @@ static void hdcp_remove_display(struct hdcp_workqueue *hdcp_work,
247
249
void hdcp_reset_display (struct hdcp_workqueue * hdcp_work , unsigned int link_index )
248
250
{
249
251
struct hdcp_workqueue * hdcp_w = & hdcp_work [link_index ];
252
+ unsigned int conn_index ;
250
253
251
254
mutex_lock (& hdcp_w -> mutex );
252
255
253
256
mod_hdcp_reset_connection (& hdcp_w -> hdcp , & hdcp_w -> output );
254
257
255
258
cancel_delayed_work (& hdcp_w -> property_validate_dwork );
256
- hdcp_w -> encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
259
+
260
+ for (conn_index = 0 ; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX ; conn_index ++ ) {
261
+ hdcp_w -> encryption_status [conn_index ] =
262
+ MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
263
+ }
257
264
258
265
process_output (hdcp_w );
259
266
@@ -290,69 +297,135 @@ static void event_callback(struct work_struct *work)
290
297
291
298
292
299
}
300
+
293
301
static void event_property_update (struct work_struct * work )
294
302
{
295
-
296
303
struct hdcp_workqueue * hdcp_work = container_of (work , struct hdcp_workqueue , property_update_work );
297
- struct amdgpu_dm_connector * aconnector = hdcp_work -> aconnector ;
298
- struct drm_device * dev = hdcp_work -> aconnector -> base . dev ;
304
+ struct amdgpu_dm_connector * aconnector = NULL ;
305
+ struct drm_device * dev ;
299
306
long ret ;
307
+ unsigned int conn_index ;
308
+ struct drm_connector * connector ;
309
+ struct drm_connector_state * conn_state ;
300
310
301
- drm_modeset_lock ( & dev -> mode_config . connection_mutex , NULL );
302
- mutex_lock ( & hdcp_work -> mutex ) ;
311
+ for ( conn_index = 0 ; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX ; conn_index ++ ) {
312
+ aconnector = hdcp_work -> aconnector [ conn_index ] ;
303
313
314
+ if (!aconnector )
315
+ continue ;
304
316
305
- if (aconnector -> base .state && aconnector -> base . state -> commit ) {
306
- ret = wait_for_completion_interruptible_timeout ( & aconnector -> base . state -> commit -> hw_done , 10 * HZ ) ;
317
+ if (! aconnector -> base .index )
318
+ continue ;
307
319
308
- if ( ret == 0 ) {
309
- DRM_ERROR ( "HDCP state unknown! Setting it to DESIRED" );
310
- hdcp_work -> encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
311
- }
312
- }
320
+ connector = & aconnector -> base ;
321
+
322
+ /* check if display connected */
323
+ if ( connector -> status != connector_status_connected )
324
+ continue ;
313
325
314
- if (aconnector -> base .state ) {
315
- if (hdcp_work -> encryption_status != MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ) {
316
- if (aconnector -> base .state -> hdcp_content_type ==
326
+ conn_state = aconnector -> base .state ;
327
+
328
+ if (!conn_state )
329
+ continue ;
330
+
331
+ dev = connector -> dev ;
332
+
333
+ if (!dev )
334
+ continue ;
335
+
336
+ drm_modeset_lock (& dev -> mode_config .connection_mutex , NULL );
337
+ mutex_lock (& hdcp_work -> mutex );
338
+
339
+ if (conn_state -> commit ) {
340
+ ret = wait_for_completion_interruptible_timeout (
341
+ & conn_state -> commit -> hw_done , 10 * HZ );
342
+ if (ret == 0 ) {
343
+ DRM_ERROR (
344
+ "HDCP state unknown! Setting it to DESIRED" );
345
+ hdcp_work -> encryption_status [conn_index ] =
346
+ MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
347
+ }
348
+ }
349
+ if (hdcp_work -> encryption_status [conn_index ] !=
350
+ MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ) {
351
+ if (conn_state -> hdcp_content_type ==
317
352
DRM_MODE_HDCP_CONTENT_TYPE0 &&
318
- hdcp_work -> encryption_status <=
319
- MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON )
320
- drm_hdcp_update_content_protection (& aconnector -> base ,
353
+ hdcp_work -> encryption_status [conn_index ] <=
354
+ MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON ) {
355
+
356
+ DRM_DEBUG_DRIVER ("[HDCP_DM] DRM_MODE_CONTENT_PROTECTION_ENABLED\n" );
357
+ drm_hdcp_update_content_protection (
358
+ connector ,
321
359
DRM_MODE_CONTENT_PROTECTION_ENABLED );
322
- else if (aconnector -> base . state -> hdcp_content_type ==
360
+ } else if (conn_state -> hdcp_content_type ==
323
361
DRM_MODE_HDCP_CONTENT_TYPE1 &&
324
- hdcp_work -> encryption_status ==
325
- MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON )
326
- drm_hdcp_update_content_protection (& aconnector -> base ,
362
+ hdcp_work -> encryption_status [conn_index ] ==
363
+ MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON ) {
364
+ drm_hdcp_update_content_protection (
365
+ connector ,
327
366
DRM_MODE_CONTENT_PROTECTION_ENABLED );
367
+ }
328
368
} else {
329
- drm_hdcp_update_content_protection (& aconnector -> base ,
330
- DRM_MODE_CONTENT_PROTECTION_DESIRED );
369
+ DRM_DEBUG_DRIVER ("[HDCP_DM] DRM_MODE_CONTENT_PROTECTION_DESIRED\n" );
370
+ drm_hdcp_update_content_protection (
371
+ connector , DRM_MODE_CONTENT_PROTECTION_DESIRED );
372
+
331
373
}
374
+ mutex_unlock (& hdcp_work -> mutex );
375
+ drm_modeset_unlock (& dev -> mode_config .connection_mutex );
332
376
}
333
-
334
- mutex_unlock (& hdcp_work -> mutex );
335
- drm_modeset_unlock (& dev -> mode_config .connection_mutex );
336
377
}
337
378
338
379
static void event_property_validate (struct work_struct * work )
339
380
{
340
381
struct hdcp_workqueue * hdcp_work =
341
382
container_of (to_delayed_work (work ), struct hdcp_workqueue , property_validate_dwork );
342
383
struct mod_hdcp_display_query query ;
343
- struct amdgpu_dm_connector * aconnector = hdcp_work -> aconnector ;
344
-
345
- if (!aconnector )
346
- return ;
384
+ struct amdgpu_dm_connector * aconnector ;
385
+ unsigned int conn_index ;
347
386
348
387
mutex_lock (& hdcp_work -> mutex );
349
388
350
- query .encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
351
- mod_hdcp_query_display (& hdcp_work -> hdcp , aconnector -> base .index , & query );
389
+ for (conn_index = 0 ; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX ;
390
+ conn_index ++ ) {
391
+ aconnector = hdcp_work -> aconnector [conn_index ];
392
+
393
+
394
+ if (!aconnector )
395
+ continue ;
396
+
397
+ if (!aconnector -> base .index )
398
+ continue ;
399
+
400
+ /* check if display connected */
401
+ if (aconnector -> base .status != connector_status_connected )
402
+ continue ;
352
403
353
- if (query .encryption_status != hdcp_work -> encryption_status ) {
354
- hdcp_work -> encryption_status = query .encryption_status ;
355
- schedule_work (& hdcp_work -> property_update_work );
404
+ if (!aconnector -> base .state )
405
+ continue ;
406
+
407
+ query .encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF ;
408
+ mod_hdcp_query_display (& hdcp_work -> hdcp , aconnector -> base .index ,
409
+ & query );
410
+
411
+ DRM_DEBUG_DRIVER ("[HDCP_DM] disp %d, connector->CP %u, (query, work): (%d, %d)\n" ,
412
+ aconnector -> base .index ,
413
+ aconnector -> base .state -> content_protection ,
414
+ query .encryption_status ,
415
+ hdcp_work -> encryption_status [conn_index ]);
416
+
417
+ if (query .encryption_status !=
418
+ hdcp_work -> encryption_status [conn_index ]) {
419
+ DRM_DEBUG_DRIVER ("[HDCP_DM] encryption_status change from %x to %x\n" ,
420
+ hdcp_work -> encryption_status [conn_index ], query .encryption_status );
421
+
422
+ hdcp_work -> encryption_status [conn_index ] =
423
+ query .encryption_status ;
424
+
425
+ DRM_DEBUG_DRIVER ("[HDCP_DM] trigger property_update_work\n" );
426
+
427
+ schedule_work (& hdcp_work -> property_update_work );
428
+ }
356
429
}
357
430
358
431
mutex_unlock (& hdcp_work -> mutex );
@@ -687,6 +760,13 @@ struct hdcp_workqueue *hdcp_create_workqueue(struct amdgpu_device *adev, struct
687
760
hdcp_work [i ].hdcp .config .ddc .funcs .read_i2c = lp_read_i2c ;
688
761
hdcp_work [i ].hdcp .config .ddc .funcs .write_dpcd = lp_write_dpcd ;
689
762
hdcp_work [i ].hdcp .config .ddc .funcs .read_dpcd = lp_read_dpcd ;
763
+
764
+ memset (hdcp_work [i ].aconnector , 0 ,
765
+ sizeof (struct amdgpu_dm_connector * ) *
766
+ AMDGPU_DM_MAX_DISPLAY_INDEX );
767
+ memset (hdcp_work [i ].encryption_status , 0 ,
768
+ sizeof (enum mod_hdcp_encryption_status ) *
769
+ AMDGPU_DM_MAX_DISPLAY_INDEX );
690
770
}
691
771
692
772
cp_psp -> funcs .update_stream_config = update_config ;
0 commit comments