@@ -1339,141 +1339,3 @@ void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitc
13391339 }
13401340}
13411341EXPORT_SYMBOL (drm_fb_xrgb8888_to_mono );
1342-
1343- static uint32_t drm_fb_nonalpha_fourcc (uint32_t fourcc )
1344- {
1345- /* only handle formats with depth != 0 and alpha channel */
1346- switch (fourcc ) {
1347- case DRM_FORMAT_ARGB1555 :
1348- return DRM_FORMAT_XRGB1555 ;
1349- case DRM_FORMAT_ABGR1555 :
1350- return DRM_FORMAT_XBGR1555 ;
1351- case DRM_FORMAT_RGBA5551 :
1352- return DRM_FORMAT_RGBX5551 ;
1353- case DRM_FORMAT_BGRA5551 :
1354- return DRM_FORMAT_BGRX5551 ;
1355- case DRM_FORMAT_ARGB8888 :
1356- return DRM_FORMAT_XRGB8888 ;
1357- case DRM_FORMAT_ABGR8888 :
1358- return DRM_FORMAT_XBGR8888 ;
1359- case DRM_FORMAT_RGBA8888 :
1360- return DRM_FORMAT_RGBX8888 ;
1361- case DRM_FORMAT_BGRA8888 :
1362- return DRM_FORMAT_BGRX8888 ;
1363- case DRM_FORMAT_ARGB2101010 :
1364- return DRM_FORMAT_XRGB2101010 ;
1365- case DRM_FORMAT_ABGR2101010 :
1366- return DRM_FORMAT_XBGR2101010 ;
1367- case DRM_FORMAT_RGBA1010102 :
1368- return DRM_FORMAT_RGBX1010102 ;
1369- case DRM_FORMAT_BGRA1010102 :
1370- return DRM_FORMAT_BGRX1010102 ;
1371- }
1372-
1373- return fourcc ;
1374- }
1375-
1376- static bool is_listed_fourcc (const uint32_t * fourccs , size_t nfourccs , uint32_t fourcc )
1377- {
1378- const uint32_t * fourccs_end = fourccs + nfourccs ;
1379-
1380- while (fourccs < fourccs_end ) {
1381- if (* fourccs == fourcc )
1382- return true;
1383- ++ fourccs ;
1384- }
1385- return false;
1386- }
1387-
1388- /**
1389- * drm_fb_build_fourcc_list - Filters a list of supported color formats against
1390- * the device's native formats
1391- * @dev: DRM device
1392- * @native_fourccs: 4CC codes of natively supported color formats
1393- * @native_nfourccs: The number of entries in @native_fourccs
1394- * @fourccs_out: Returns 4CC codes of supported color formats
1395- * @nfourccs_out: The number of available entries in @fourccs_out
1396- *
1397- * This function create a list of supported color format from natively
1398- * supported formats and additional emulated formats.
1399- * At a minimum, most userspace programs expect at least support for
1400- * XRGB8888 on the primary plane. Devices that have to emulate the
1401- * format, and possibly others, can use drm_fb_build_fourcc_list() to
1402- * create a list of supported color formats. The returned list can
1403- * be handed over to drm_universal_plane_init() et al. Native formats
1404- * will go before emulated formats. Native formats with alpha channel
1405- * will be replaced by such without, as primary planes usually don't
1406- * support alpha. Other heuristics might be applied
1407- * to optimize the order. Formats near the beginning of the list are
1408- * usually preferred over formats near the end of the list.
1409- *
1410- * Returns:
1411- * The number of color-formats 4CC codes returned in @fourccs_out.
1412- */
1413- size_t drm_fb_build_fourcc_list (struct drm_device * dev ,
1414- const u32 * native_fourccs , size_t native_nfourccs ,
1415- u32 * fourccs_out , size_t nfourccs_out )
1416- {
1417- /*
1418- * XRGB8888 is the default fallback format for most of userspace
1419- * and it's currently the only format that should be emulated for
1420- * the primary plane. Only if there's ever another default fallback,
1421- * it should be added here.
1422- */
1423- static const uint32_t extra_fourccs [] = {
1424- DRM_FORMAT_XRGB8888 ,
1425- };
1426- static const size_t extra_nfourccs = ARRAY_SIZE (extra_fourccs );
1427-
1428- u32 * fourccs = fourccs_out ;
1429- const u32 * fourccs_end = fourccs_out + nfourccs_out ;
1430- size_t i ;
1431-
1432- /*
1433- * The device's native formats go first.
1434- */
1435-
1436- for (i = 0 ; i < native_nfourccs ; ++ i ) {
1437- /*
1438- * Several DTs, boot loaders and firmware report native
1439- * alpha formats that are non-alpha formats instead. So
1440- * replace alpha formats by non-alpha formats.
1441- */
1442- u32 fourcc = drm_fb_nonalpha_fourcc (native_fourccs [i ]);
1443-
1444- if (is_listed_fourcc (fourccs_out , fourccs - fourccs_out , fourcc )) {
1445- continue ; /* skip duplicate entries */
1446- } else if (fourccs == fourccs_end ) {
1447- drm_warn (dev , "Ignoring native format %p4cc\n" , & fourcc );
1448- continue ; /* end of available output buffer */
1449- }
1450-
1451- drm_dbg_kms (dev , "adding native format %p4cc\n" , & fourcc );
1452-
1453- * fourccs = fourcc ;
1454- ++ fourccs ;
1455- }
1456-
1457- /*
1458- * The extra formats, emulated by the driver, go second.
1459- */
1460-
1461- for (i = 0 ; (i < extra_nfourccs ) && (fourccs < fourccs_end ); ++ i ) {
1462- u32 fourcc = extra_fourccs [i ];
1463-
1464- if (is_listed_fourcc (fourccs_out , fourccs - fourccs_out , fourcc )) {
1465- continue ; /* skip duplicate and native entries */
1466- } else if (fourccs == fourccs_end ) {
1467- drm_warn (dev , "Ignoring emulated format %p4cc\n" , & fourcc );
1468- continue ; /* end of available output buffer */
1469- }
1470-
1471- drm_dbg_kms (dev , "adding emulated format %p4cc\n" , & fourcc );
1472-
1473- * fourccs = fourcc ;
1474- ++ fourccs ;
1475- }
1476-
1477- return fourccs - fourccs_out ;
1478- }
1479- EXPORT_SYMBOL (drm_fb_build_fourcc_list );
0 commit comments