drm: Add Client Cap for advance degamma mode

A client cap advance degamma mode is introduced. Minimum requirement
for a client to set this capability is if it can use 64 bit LUT
values as defined by the structure drm_color_lut_ext on a supported
platform.

If not set driver will work in legacy mode.

v2: Fix typo (Bhanu)

Signed-off-by: Borah, Chaitanya Kumar <chaitanya.kumar.borah@intel.com>
This commit is contained in:
Borah, Chaitanya Kumar 2023-04-18 18:38:51 +05:30 committed by Junxiao Chang
parent e17e02f9d3
commit aab52f1100
6 changed files with 39 additions and 1 deletions

View File

@ -415,10 +415,13 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
} else if (property == config->prop_vrr_enabled) {
state->vrr_enabled = val;
} else if (property == config->degamma_lut_property) {
ssize_t size = state->advance_degamma_mode_active ?
sizeof(struct drm_color_lut_ext) :
sizeof(struct drm_color_lut);
ret = drm_atomic_replace_property_blob_from_id(dev,
&state->degamma_lut,
val,
-1, sizeof(struct drm_color_lut),
-1, size,
&replaced);
state->color_mgmt_changed |= replaced;
return ret;
@ -1060,6 +1063,8 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
crtc_state->advance_gamma_mode_active =
state->advance_gamma_mode_active;
crtc_state->advance_degamma_mode_active =
state->advance_degamma_mode_active;
ret = drm_atomic_crtc_set_property(crtc,
crtc_state, prop, prop_value);
break;
@ -1397,6 +1402,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
state->acquire_ctx = &ctx;
state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
state->advance_gamma_mode_active = file_priv->advance_gamma_mode_active;
state->advance_degamma_mode_active = file_priv->advance_degamma_mode_active;
retry:
copied_objs = 0;

View File

@ -367,6 +367,11 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
return -EINVAL;
file_priv->advance_gamma_mode_active = req->value;
break;
case DRM_CLIENT_CAP_ADVANCE_DEGAMMA_MODES:
if (req->value > 1)
return -EINVAL;
file_priv->advance_degamma_mode_active = req->value;
break;
default:
return -EINVAL;
}

View File

@ -399,6 +399,7 @@ struct drm_atomic_state {
*/
bool duplicated : 1;
bool advance_gamma_mode_active : 1;
bool advance_degamma_mode_active : 1;
struct __drm_planes_state *planes;
struct __drm_crtcs_state *crtcs;
int num_connector;

View File

@ -162,6 +162,11 @@ struct drm_crtc_state {
*/
bool advance_gamma_mode_active : 1;
/**
* This is to indicate advance degamma mode support
*/
bool advance_degamma_mode_active : 1;
/**
* @no_vblank:
*
@ -1045,6 +1050,9 @@ struct drm_crtc {
/** To handle advance gamma mode support */
bool advance_gamma_mode_active : 1;
/** To handle advance degamma mode support */
bool advance_degamma_mode_active : 1;
/**
* @mode:
*

View File

@ -214,6 +214,14 @@ struct drm_file {
*/
bool advance_gamma_mode_active : 1;
/**
* This is to enable advance degamma modes using
* 64 bit LUT values
*
* True if client understands advance degamma
*/
bool advance_degamma_mode_active : 1;
/**
* @was_master:
*

View File

@ -846,6 +846,16 @@ struct drm_get_cap {
*/
#define DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES 6
/**
* DRM_CLIENT_CAP_ADVANCE_DEGAMMA_MODES
*
* Add support for advance degamma mode UAPI
* If set to 1, DRM will enable advance degamma mode
* UAPI to process degamma mode with 64 bit LUT
* values
*/
#define DRM_CLIENT_CAP_ADVANCE_DEGAMMA_MODES 7
/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
struct drm_set_client_cap {
__u64 capability;