![]() |
|
|||
0001 /* 0002 * Copyright (c) 2016 Intel Corporation 0003 * 0004 * Permission to use, copy, modify, distribute, and sell this software and its 0005 * documentation for any purpose is hereby granted without fee, provided that 0006 * the above copyright notice appear in all copies and that both that copyright 0007 * notice and this permission notice appear in supporting documentation, and 0008 * that the name of the copyright holders not be used in advertising or 0009 * publicity pertaining to distribution of the software without specific, 0010 * written prior permission. The copyright holders make no representations 0011 * about the suitability of this software for any purpose. It is provided "as 0012 * is" without express or implied warranty. 0013 * 0014 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 0015 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 0016 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 0017 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 0018 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 0019 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 0020 * OF THIS SOFTWARE. 0021 */ 0022 0023 #ifndef __DRM_COLOR_MGMT_H__ 0024 #define __DRM_COLOR_MGMT_H__ 0025 0026 #include <linux/ctype.h> 0027 #include <drm/drm_property.h> 0028 0029 struct drm_crtc; 0030 struct drm_plane; 0031 0032 /** 0033 * drm_color_lut_extract - clamp and round LUT entries 0034 * @user_input: input value 0035 * @bit_precision: number of bits the hw LUT supports 0036 * 0037 * Extract a degamma/gamma LUT value provided by user (in the form of 0038 * &drm_color_lut entries) and round it to the precision supported by the 0039 * hardware. 0040 */ 0041 static inline u32 drm_color_lut_extract(u32 user_input, int bit_precision) 0042 { 0043 u32 val = user_input; 0044 u32 max = 0xffff >> (16 - bit_precision); 0045 0046 /* Round only if we're not using full precision. */ 0047 if (bit_precision < 16) { 0048 val += 1UL << (16 - bit_precision - 1); 0049 val >>= 16 - bit_precision; 0050 } 0051 0052 return clamp_val(val, 0, max); 0053 } 0054 0055 u64 drm_color_ctm_s31_32_to_qm_n(u64 user_input, u32 m, u32 n); 0056 0057 void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, 0058 uint degamma_lut_size, 0059 bool has_ctm, 0060 uint gamma_lut_size); 0061 0062 int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, 0063 int gamma_size); 0064 0065 /** 0066 * drm_color_lut_size - calculate the number of entries in the LUT 0067 * @blob: blob containing the LUT 0068 * 0069 * Returns: 0070 * The number of entries in the color LUT stored in @blob. 0071 */ 0072 static inline int drm_color_lut_size(const struct drm_property_blob *blob) 0073 { 0074 return blob->length / sizeof(struct drm_color_lut); 0075 } 0076 0077 enum drm_color_encoding { 0078 DRM_COLOR_YCBCR_BT601, 0079 DRM_COLOR_YCBCR_BT709, 0080 DRM_COLOR_YCBCR_BT2020, 0081 DRM_COLOR_ENCODING_MAX, 0082 }; 0083 0084 enum drm_color_range { 0085 DRM_COLOR_YCBCR_LIMITED_RANGE, 0086 DRM_COLOR_YCBCR_FULL_RANGE, 0087 DRM_COLOR_RANGE_MAX, 0088 }; 0089 0090 int drm_plane_create_color_properties(struct drm_plane *plane, 0091 u32 supported_encodings, 0092 u32 supported_ranges, 0093 enum drm_color_encoding default_encoding, 0094 enum drm_color_range default_range); 0095 0096 /** 0097 * enum drm_color_lut_tests - hw-specific LUT tests to perform 0098 * 0099 * The drm_color_lut_check() function takes a bitmask of the values here to 0100 * determine which tests to apply to a userspace-provided LUT. 0101 */ 0102 enum drm_color_lut_tests { 0103 /** 0104 * @DRM_COLOR_LUT_EQUAL_CHANNELS: 0105 * 0106 * Checks whether the entries of a LUT all have equal values for the 0107 * red, green, and blue channels. Intended for hardware that only 0108 * accepts a single value per LUT entry and assumes that value applies 0109 * to all three color components. 0110 */ 0111 DRM_COLOR_LUT_EQUAL_CHANNELS = BIT(0), 0112 0113 /** 0114 * @DRM_COLOR_LUT_NON_DECREASING: 0115 * 0116 * Checks whether the entries of a LUT are always flat or increasing 0117 * (never decreasing). 0118 */ 0119 DRM_COLOR_LUT_NON_DECREASING = BIT(1), 0120 }; 0121 0122 int drm_color_lut_check(const struct drm_property_blob *lut, u32 tests); 0123 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |