@@ -260,13 +260,70 @@ static void apple_crtc_cleanup(struct drm_crtc *crtc)
260260 kfree (to_apple_crtc (crtc ));
261261}
262262
263+ static int apple_crtc_parse_crc_source (const char * source , bool * enabled )
264+ {
265+ int ret = 0 ;
266+
267+ if (!source ) {
268+ * enabled = false;
269+ } else if (strcmp (source , "auto" ) == 0 ) {
270+ * enabled = true;
271+ } else {
272+ * enabled = false;
273+ ret = - EINVAL ;
274+ }
275+
276+ return ret ;
277+ }
278+
279+ static int apple_crtc_set_crc_source (struct drm_crtc * crtc , const char * source )
280+ {
281+ bool enabled = false;
282+
283+ int ret = apple_crtc_parse_crc_source (source , & enabled );
284+
285+ if (!ret )
286+ dcp_set_crc (crtc , enabled );
287+
288+ return ret ;
289+ }
290+
291+ static int apple_crtc_verify_crc_source (struct drm_crtc * crtc ,
292+ const char * source ,
293+ size_t * values_cnt )
294+ {
295+ bool enabled ;
296+
297+ if (apple_crtc_parse_crc_source (source , & enabled ) < 0 ) {
298+ pr_warn ("dcp: Invalid CRC source name %s\n" , source );
299+ return - EINVAL ;
300+ }
301+
302+ * values_cnt = 1 ;
303+
304+ return 0 ;
305+ }
306+
307+ static const char * const apple_crtc_crc_sources [] = {"auto" };
308+
309+ static const char * const * apple_crtc_get_crc_sources (struct drm_crtc * crtc ,
310+ size_t * count )
311+ {
312+ * count = ARRAY_SIZE (apple_crtc_crc_sources );
313+ return apple_crtc_crc_sources ;
314+ }
315+
263316static const struct drm_crtc_funcs apple_crtc_funcs = {
264317 .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state ,
265318 .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state ,
266319 .destroy = apple_crtc_cleanup ,
267320 .page_flip = drm_atomic_helper_page_flip ,
268321 .reset = drm_atomic_helper_crtc_reset ,
269322 .set_config = drm_atomic_helper_set_config ,
323+ .set_crc_source = apple_crtc_set_crc_source ,
324+ .verify_crc_source = apple_crtc_verify_crc_source ,
325+ .get_crc_sources = apple_crtc_get_crc_sources ,
326+
270327};
271328
272329static const struct drm_mode_config_funcs apple_mode_config_funcs = {
0 commit comments