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