drm: Extract drm_color_mgmt.[hc]
For both the new degamm/lut/gamma atomic combo, and the old legacy gamma tables. Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/1474448370-32227-5-git-send-email-daniel.vetter@ffwll.ch
This commit is contained in:
56
include/drm/drm_color_mgmt.h
Normal file
56
include/drm/drm_color_mgmt.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Intel Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __DRM_COLOR_MGMT_H__
|
||||
#define __DRM_COLOR_MGMT_H__
|
||||
|
||||
#include <linux/ctype.h>
|
||||
|
||||
void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
|
||||
uint degamma_lut_size,
|
||||
bool has_ctm,
|
||||
uint gamma_lut_size);
|
||||
|
||||
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
|
||||
int gamma_size);
|
||||
|
||||
/*
|
||||
* Extract a degamma/gamma LUT value provided by user and round it to the
|
||||
* precision supported by the hardware.
|
||||
*/
|
||||
static inline uint32_t drm_color_lut_extract(uint32_t user_input,
|
||||
uint32_t bit_precision)
|
||||
{
|
||||
uint32_t val = user_input;
|
||||
uint32_t max = 0xffff >> (16 - bit_precision);
|
||||
|
||||
/* Round only if we're not using full precision. */
|
||||
if (bit_precision < 16) {
|
||||
val += 1UL << (16 - bit_precision - 1);
|
||||
val >>= 16 - bit_precision;
|
||||
}
|
||||
|
||||
return clamp_val(val, 0, max);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@@ -46,6 +46,7 @@
|
||||
#include <drm/drm_edid.h>
|
||||
#include <drm/drm_plane.h>
|
||||
#include <drm/drm_blend.h>
|
||||
#include <drm/drm_color_mgmt.h>
|
||||
|
||||
struct drm_device;
|
||||
struct drm_mode_set;
|
||||
@@ -1337,9 +1338,6 @@ extern void drm_mode_config_init(struct drm_device *dev);
|
||||
extern void drm_mode_config_reset(struct drm_device *dev);
|
||||
extern void drm_mode_config_cleanup(struct drm_device *dev);
|
||||
|
||||
extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
|
||||
int gamma_size);
|
||||
|
||||
extern int drm_mode_set_config_internal(struct drm_mode_set *set);
|
||||
|
||||
extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
|
||||
@@ -1349,11 +1347,6 @@ extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
|
||||
extern void drm_mode_put_tile_group(struct drm_device *dev,
|
||||
struct drm_tile_group *tg);
|
||||
|
||||
extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
|
||||
uint degamma_lut_size,
|
||||
bool has_ctm,
|
||||
uint gamma_lut_size);
|
||||
|
||||
/* Helpers */
|
||||
static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
|
||||
uint32_t id)
|
||||
@@ -1363,25 +1356,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
|
||||
return mo ? obj_to_crtc(mo) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract a degamma/gamma LUT value provided by user and round it to the
|
||||
* precision supported by the hardware.
|
||||
*/
|
||||
static inline uint32_t drm_color_lut_extract(uint32_t user_input,
|
||||
uint32_t bit_precision)
|
||||
{
|
||||
uint32_t val = user_input;
|
||||
uint32_t max = 0xffff >> (16 - bit_precision);
|
||||
|
||||
/* Round only if we're not using full precision. */
|
||||
if (bit_precision < 16) {
|
||||
val += 1UL << (16 - bit_precision - 1);
|
||||
val >>= 16 - bit_precision;
|
||||
}
|
||||
|
||||
return clamp_val(val, 0, max);
|
||||
}
|
||||
|
||||
#define drm_for_each_crtc(crtc, dev) \
|
||||
list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
|
||||
|
||||
|
مرجع در شماره جدید
Block a user