diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-09-21 04:59:28 -0400 |
---|---|---|
committer | Sean Paul <seanpaul@chromium.org> | 2016-09-22 03:04:02 -0400 |
commit | f1e2f66ce2d9f732fec184ab885fba4b53c06016 (patch) | |
tree | 5881a515e6cd2e94a14d17ca36a40eeed0e9d023 /include/drm | |
parent | 1e4d84c6589e9e9d19884e705085fe4a1885b012 (diff) |
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
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drm_color_mgmt.h | 56 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 28 |
2 files changed, 57 insertions, 27 deletions
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h new file mode 100644 index 000000000000..1e01c58bbe81 --- /dev/null +++ b/include/drm/drm_color_mgmt.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016 Intel Corporation | ||
3 | * | ||
4 | * Permission to use, copy, modify, distribute, and sell this software and its | ||
5 | * documentation for any purpose is hereby granted without fee, provided that | ||
6 | * the above copyright notice appear in all copies and that both that copyright | ||
7 | * notice and this permission notice appear in supporting documentation, and | ||
8 | * that the name of the copyright holders not be used in advertising or | ||
9 | * publicity pertaining to distribution of the software without specific, | ||
10 | * written prior permission. The copyright holders make no representations | ||
11 | * about the suitability of this software for any purpose. It is provided "as | ||
12 | * is" without express or implied warranty. | ||
13 | * | ||
14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | ||
16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | ||
18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
20 | * OF THIS SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __DRM_COLOR_MGMT_H__ | ||
24 | #define __DRM_COLOR_MGMT_H__ | ||
25 | |||
26 | #include <linux/ctype.h> | ||
27 | |||
28 | void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, | ||
29 | uint degamma_lut_size, | ||
30 | bool has_ctm, | ||
31 | uint gamma_lut_size); | ||
32 | |||
33 | int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, | ||
34 | int gamma_size); | ||
35 | |||
36 | /* | ||
37 | * Extract a degamma/gamma LUT value provided by user and round it to the | ||
38 | * precision supported by the hardware. | ||
39 | */ | ||
40 | static inline uint32_t drm_color_lut_extract(uint32_t user_input, | ||
41 | uint32_t bit_precision) | ||
42 | { | ||
43 | uint32_t val = user_input; | ||
44 | uint32_t max = 0xffff >> (16 - bit_precision); | ||
45 | |||
46 | /* Round only if we're not using full precision. */ | ||
47 | if (bit_precision < 16) { | ||
48 | val += 1UL << (16 - bit_precision - 1); | ||
49 | val >>= 16 - bit_precision; | ||
50 | } | ||
51 | |||
52 | return clamp_val(val, 0, max); | ||
53 | } | ||
54 | |||
55 | |||
56 | #endif | ||
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 8d06cabede59..a544b7502493 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <drm/drm_edid.h> | 46 | #include <drm/drm_edid.h> |
47 | #include <drm/drm_plane.h> | 47 | #include <drm/drm_plane.h> |
48 | #include <drm/drm_blend.h> | 48 | #include <drm/drm_blend.h> |
49 | #include <drm/drm_color_mgmt.h> | ||
49 | 50 | ||
50 | struct drm_device; | 51 | struct drm_device; |
51 | struct drm_mode_set; | 52 | struct drm_mode_set; |
@@ -1337,9 +1338,6 @@ extern void drm_mode_config_init(struct drm_device *dev); | |||
1337 | extern void drm_mode_config_reset(struct drm_device *dev); | 1338 | extern void drm_mode_config_reset(struct drm_device *dev); |
1338 | extern void drm_mode_config_cleanup(struct drm_device *dev); | 1339 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
1339 | 1340 | ||
1340 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, | ||
1341 | int gamma_size); | ||
1342 | |||
1343 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); | 1341 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
1344 | 1342 | ||
1345 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, | 1343 | 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, | |||
1349 | extern void drm_mode_put_tile_group(struct drm_device *dev, | 1347 | extern void drm_mode_put_tile_group(struct drm_device *dev, |
1350 | struct drm_tile_group *tg); | 1348 | struct drm_tile_group *tg); |
1351 | 1349 | ||
1352 | extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, | ||
1353 | uint degamma_lut_size, | ||
1354 | bool has_ctm, | ||
1355 | uint gamma_lut_size); | ||
1356 | |||
1357 | /* Helpers */ | 1350 | /* Helpers */ |
1358 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, | 1351 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
1359 | uint32_t id) | 1352 | uint32_t id) |
@@ -1363,25 +1356,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, | |||
1363 | return mo ? obj_to_crtc(mo) : NULL; | 1356 | return mo ? obj_to_crtc(mo) : NULL; |
1364 | } | 1357 | } |
1365 | 1358 | ||
1366 | /* | ||
1367 | * Extract a degamma/gamma LUT value provided by user and round it to the | ||
1368 | * precision supported by the hardware. | ||
1369 | */ | ||
1370 | static inline uint32_t drm_color_lut_extract(uint32_t user_input, | ||
1371 | uint32_t bit_precision) | ||
1372 | { | ||
1373 | uint32_t val = user_input; | ||
1374 | uint32_t max = 0xffff >> (16 - bit_precision); | ||
1375 | |||
1376 | /* Round only if we're not using full precision. */ | ||
1377 | if (bit_precision < 16) { | ||
1378 | val += 1UL << (16 - bit_precision - 1); | ||
1379 | val >>= 16 - bit_precision; | ||
1380 | } | ||
1381 | |||
1382 | return clamp_val(val, 0, max); | ||
1383 | } | ||
1384 | |||
1385 | #define drm_for_each_crtc(crtc, dev) \ | 1359 | #define drm_for_each_crtc(crtc, dev) \ |
1386 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) | 1360 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) |
1387 | 1361 | ||