Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: add helper functions for YCBCR420 handling

This patch adds helper functions for YCBCR 420 handling.
These functions do:
- check if a given video mode is YCBCR 420 only mode.
- check if a given video mode is YCBCR 420 also mode.

V2: Added YCBCR functions as helpers in DRM layer, instead of
keeping it in I915 layer.
V3: Added handling for YCBCR-420 only modes too.
V4: EXPORT_SYMBOL(drm_find_hdmi_output_type)
V5: Addressed review comments from Danvet:
- %s/drm_find_hdmi_output_type/drm_display_info_hdmi_output_type
- %s/drm_can_support_ycbcr_output/drm_display_supports_ycbcr_output
- %s/drm_can_support_this_ycbcr_output/
drm_display_supports_this_ycbcr_output
- pass drm_display_info instead of drm_connector for consistency
- For drm_get_highest_quality_ycbcr_supported doc, move the variable
description above, and then the function description.
V6: Add only YCBCR420 helpers (Ville)
V7: Addressed review comments from Ville
- Remove cea_vic_valid() check.
- Fix indentation.
- Make input parameters to helpers, const.

Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1499960000-9232-9-git-send-email-shashank.sharma@intel.com
[vsyrjala: Fix sparse indentation warn]
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

authored by

Shashank Sharma and committed by
Ville Syrjälä
2570fe25 e6a9a2c3

+64
+58
drivers/gpu/drm/drm_modes.c
··· 1605 1605 out: 1606 1606 return ret; 1607 1607 } 1608 + 1609 + /** 1610 + * drm_mode_is_420_only - if a given videomode can be only supported in YCBCR420 1611 + * output format 1612 + * 1613 + * @connector: drm connector under action. 1614 + * @mode: video mode to be tested. 1615 + * 1616 + * Returns: 1617 + * true if the mode can be supported in YCBCR420 format 1618 + * false if not. 1619 + */ 1620 + bool drm_mode_is_420_only(const struct drm_display_info *display, 1621 + const struct drm_display_mode *mode) 1622 + { 1623 + u8 vic = drm_match_cea_mode(mode); 1624 + 1625 + return test_bit(vic, display->hdmi.y420_vdb_modes); 1626 + } 1627 + EXPORT_SYMBOL(drm_mode_is_420_only); 1628 + 1629 + /** 1630 + * drm_mode_is_420_also - if a given videomode can be supported in YCBCR420 1631 + * output format also (along with RGB/YCBCR444/422) 1632 + * 1633 + * @display: display under action. 1634 + * @mode: video mode to be tested. 1635 + * 1636 + * Returns: 1637 + * true if the mode can be support YCBCR420 format 1638 + * false if not. 1639 + */ 1640 + bool drm_mode_is_420_also(const struct drm_display_info *display, 1641 + const struct drm_display_mode *mode) 1642 + { 1643 + u8 vic = drm_match_cea_mode(mode); 1644 + 1645 + return test_bit(vic, display->hdmi.y420_cmdb_modes); 1646 + } 1647 + EXPORT_SYMBOL(drm_mode_is_420_also); 1648 + /** 1649 + * drm_mode_is_420 - if a given videomode can be supported in YCBCR420 1650 + * output format 1651 + * 1652 + * @display: display under action. 1653 + * @mode: video mode to be tested. 1654 + * 1655 + * Returns: 1656 + * true if the mode can be supported in YCBCR420 format 1657 + * false if not. 1658 + */ 1659 + bool drm_mode_is_420(const struct drm_display_info *display, 1660 + const struct drm_display_mode *mode) 1661 + { 1662 + return drm_mode_is_420_only(display, mode) || 1663 + drm_mode_is_420_also(display, mode); 1664 + } 1665 + EXPORT_SYMBOL(drm_mode_is_420);
+6
include/drm/drm_modes.h
··· 452 452 const struct drm_mode_modeinfo *in); 453 453 void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); 454 454 void drm_mode_debug_printmodeline(const struct drm_display_mode *mode); 455 + bool drm_mode_is_420_only(const struct drm_display_info *display, 456 + const struct drm_display_mode *mode); 457 + bool drm_mode_is_420_also(const struct drm_display_info *display, 458 + const struct drm_display_mode *mode); 459 + bool drm_mode_is_420(const struct drm_display_info *display, 460 + const struct drm_display_mode *mode); 455 461 456 462 struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, 457 463 int hdisplay, int vdisplay, int vrefresh,