18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) Jernej Skrabec <jernej.skrabec@siol.net>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _SUN8I_CSC_H_
78c2ecf20Sopenharmony_ci#define _SUN8I_CSC_H_
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <drm/drm_color_mgmt.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistruct sun8i_mixer;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* VI channel CSC units offsets */
148c2ecf20Sopenharmony_ci#define CCSC00_OFFSET 0xAA050
158c2ecf20Sopenharmony_ci#define CCSC01_OFFSET 0xFA050
168c2ecf20Sopenharmony_ci#define CCSC10_OFFSET 0xA0000
178c2ecf20Sopenharmony_ci#define CCSC11_OFFSET 0xF0000
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define SUN8I_CSC_CTRL(base)		((base) + 0x0)
208c2ecf20Sopenharmony_ci#define SUN8I_CSC_COEFF(base, i)	((base) + 0x10 + 4 * (i))
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define SUN8I_CSC_CTRL_EN		BIT(0)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cienum sun8i_csc_mode {
258c2ecf20Sopenharmony_ci	SUN8I_CSC_MODE_OFF,
268c2ecf20Sopenharmony_ci	SUN8I_CSC_MODE_YUV2RGB,
278c2ecf20Sopenharmony_ci	SUN8I_CSC_MODE_YVU2RGB,
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_civoid sun8i_csc_set_ccsc_coefficients(struct sun8i_mixer *mixer, int layer,
318c2ecf20Sopenharmony_ci				     enum sun8i_csc_mode mode,
328c2ecf20Sopenharmony_ci				     enum drm_color_encoding encoding,
338c2ecf20Sopenharmony_ci				     enum drm_color_range range);
348c2ecf20Sopenharmony_civoid sun8i_csc_enable_ccsc(struct sun8i_mixer *mixer, int layer, bool enable);
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#endif
37