Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1 | /* 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 Kwong | dcc96ff | 2016-07-29 03:06:44 -0400 | [diff] [blame] | 17 | #include "sde_hw_top.h" |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 18 | |
| 19 | struct sde_hw_cdm; |
| 20 | |
| 21 | struct 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 Kwong | dcc96ff | 2016-07-29 03:06:44 -0400 | [diff] [blame] | 27 | const struct sde_format *output_fmt; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 28 | u32 output_type; |
| 29 | int flags; |
| 30 | }; |
| 31 | |
| 32 | enum 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 | |
| 40 | enum sde_hw_cdwn_output_type { |
| 41 | CDM_CDWN_OUTPUT_HDMI, |
| 42 | CDM_CDWN_OUTPUT_WB, |
| 43 | }; |
| 44 | |
| 45 | enum 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 | */ |
| 60 | struct sde_hw_cdm_ops { |
| 61 | /** |
| 62 | * Programs the CSC matrix for conversion from RGB space to YUV space, |
Alan Kwong | dcc96ff | 2016-07-29 03:06:44 -0400 | [diff] [blame] | 63 | * it is optional to call this function as this matrix is automatically |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 64 | * 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 | |
| 93 | struct 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 Kwong | dcc96ff | 2016-07-29 03:06:44 -0400 | [diff] [blame] | 101 | /* mdp top hw driver */ |
| 102 | struct sde_hw_mdp *hw_mdp; |
| 103 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 104 | /* ops */ |
| 105 | struct sde_hw_cdm_ops ops; |
| 106 | }; |
| 107 | |
| 108 | /** |
Lloyd Atkinson | 6b3b9dd | 2016-08-10 18:45:31 -0400 | [diff] [blame] | 109 | * sde_hw_cdm_init - initializes the cdm hw driver object. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 110 | * 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 Kwong | dcc96ff | 2016-07-29 03:06:44 -0400 | [diff] [blame] | 114 | * @hw_mdp: pointer to mdp top hw driver object |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 115 | */ |
| 116 | struct sde_hw_cdm *sde_hw_cdm_init(enum sde_cdm idx, |
| 117 | void __iomem *addr, |
Alan Kwong | dcc96ff | 2016-07-29 03:06:44 -0400 | [diff] [blame] | 118 | struct sde_mdss_cfg *m, |
| 119 | struct sde_hw_mdp *hw_mdp); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 120 | |
Lloyd Atkinson | 6b3b9dd | 2016-08-10 18:45:31 -0400 | [diff] [blame] | 121 | /** |
| 122 | * sde_hw_cdm_destroy - destroys CDM driver context |
| 123 | * @cdm: pointer to CDM driver context |
| 124 | */ |
| 125 | void sde_hw_cdm_destroy(struct sde_hw_cdm *cdm); |
| 126 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 127 | #endif /*_SDE_HW_CDM_H */ |