blob: 264b8a418573e31917c5d1aedb69ca2e2667e57c [file] [log] [blame]
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _SDE_HW_CDM_H
14#define _SDE_HW_CDM_H
15
16#include "sde_hw_mdss.h"
Alan Kwongdcc96ff2016-07-29 03:06:44 -040017#include "sde_hw_top.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070018
19struct sde_hw_cdm;
20
21struct sde_hw_cdm_cfg {
22 u32 output_width;
23 u32 output_height;
24 u32 output_bit_depth;
25 u32 h_cdwn_type;
26 u32 v_cdwn_type;
Alan Kwongdcc96ff2016-07-29 03:06:44 -040027 const struct sde_format *output_fmt;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070028 u32 output_type;
29 int flags;
30};
31
32enum sde_hw_cdwn_type {
33 CDM_CDWN_DISABLE,
34 CDM_CDWN_PIXEL_DROP,
35 CDM_CDWN_AVG,
36 CDM_CDWN_COSITE,
37 CDM_CDWN_OFFSITE,
38};
39
40enum sde_hw_cdwn_output_type {
41 CDM_CDWN_OUTPUT_HDMI,
42 CDM_CDWN_OUTPUT_WB,
43};
44
45enum sde_hw_cdwn_output_bit_depth {
46 CDM_CDWN_OUTPUT_8BIT,
47 CDM_CDWN_OUTPUT_10BIT,
48};
49
50/**
51 * struct sde_hw_cdm_ops : Interface to the chroma down Hw driver functions
52 * Assumption is these functions will be called after
53 * clocks are enabled
54 * @setup_csc: Programs the csc matrix
55 * @setup_cdwn: Sets up the chroma down sub module
56 * @enable: Enables the output to interface and programs the
57 * output packer
58 * @disable: Puts the cdm in bypass mode
59 */
60struct sde_hw_cdm_ops {
61 /**
62 * Programs the CSC matrix for conversion from RGB space to YUV space,
Alan Kwongdcc96ff2016-07-29 03:06:44 -040063 * it is optional to call this function as this matrix is automatically
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070064 * set during initialization, user should call this if it wants
65 * to program a different matrix than default matrix.
66 * @cdm: Pointer to the chroma down context structure
67 * @data Pointer to CSC configuration data
68 */
69 void (*setup_csc_data)(struct sde_hw_cdm *cdm,
70 struct sde_csc_cfg *data);
71
72 /**
73 * Programs the Chroma downsample part.
74 * @cdm Pointer to chroma down context
75 */
76 int (*setup_cdwn)(struct sde_hw_cdm *cdm,
77 struct sde_hw_cdm_cfg *cfg);
78
79 /**
80 * Enable the CDM module
81 * @cdm Pointer to chroma down context
82 */
83 int (*enable)(struct sde_hw_cdm *cdm,
84 struct sde_hw_cdm_cfg *cfg);
85
86 /**
87 * Disable the CDM module
88 * @cdm Pointer to chroma down context
89 */
90 void (*disable)(struct sde_hw_cdm *cdm);
91};
92
93struct sde_hw_cdm {
94 /* base */
95 struct sde_hw_blk_reg_map hw;
96
97 /* chroma down */
98 const struct sde_cdm_cfg *cdm_hw_cap;
99 enum sde_cdm idx;
100
Alan Kwongdcc96ff2016-07-29 03:06:44 -0400101 /* mdp top hw driver */
102 struct sde_hw_mdp *hw_mdp;
103
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700104 /* ops */
105 struct sde_hw_cdm_ops ops;
106};
107
108/**
Lloyd Atkinson6b3b9dd2016-08-10 18:45:31 -0400109 * sde_hw_cdm_init - initializes the cdm hw driver object.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700110 * should be called once before accessing every cdm.
111 * @idx: cdm index for which driver object is required
112 * @addr: mapped register io address of MDP
113 * @m : pointer to mdss catalog data
Alan Kwongdcc96ff2016-07-29 03:06:44 -0400114 * @hw_mdp: pointer to mdp top hw driver object
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700115 */
116struct sde_hw_cdm *sde_hw_cdm_init(enum sde_cdm idx,
117 void __iomem *addr,
Alan Kwongdcc96ff2016-07-29 03:06:44 -0400118 struct sde_mdss_cfg *m,
119 struct sde_hw_mdp *hw_mdp);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700120
Lloyd Atkinson6b3b9dd2016-08-10 18:45:31 -0400121/**
122 * sde_hw_cdm_destroy - destroys CDM driver context
123 * @cdm: pointer to CDM driver context
124 */
125void sde_hw_cdm_destroy(struct sde_hw_cdm *cdm);
126
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700127#endif /*_SDE_HW_CDM_H */