4 * Header file for HISTOGRAM module in TI's OMAP3 Camera ISP
6 * Copyright (C) 2009 Texas Instruments, Inc.
9 * Sergio Aguirre <saaguirre@ti.com>
12 * This package is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 #ifndef OMAP_ISP_HIST_H
22 #define OMAP_ISP_HIST_H
24 #include <plat/isp_user.h>
26 #define MAX_REGIONS 0x4
27 #define MAX_WB_GAIN 255
28 #define MIN_WB_GAIN 0x0
29 #define MAX_BIT_WIDTH 14
30 #define MIN_BIT_WIDTH 8
32 #define ISPHIST_PCR_EN (1 << 0)
33 #define HIST_MEM_SIZE 1024
34 #define ISPHIST_CNT_CLR_EN (1 << 7)
36 #define WRITE_SOURCE(reg, source) \
37 (reg = (reg & ~(ISPHIST_CNT_SOURCE_MASK)) \
38 | (source << ISPHIST_CNT_SOURCE_SHIFT))
40 #define WRITE_HV_INFO(reg, hv_info) \
41 (reg = ((reg & ~(ISPHIST_HV_INFO_MASK)) \
42 | (hv_info & ISPHIST_HV_INFO_MASK)))
44 #define WRITE_RADD(reg, radd) \
45 (reg = (reg & ~(ISPHIST_RADD_MASK)) \
46 | (radd << ISPHIST_RADD_SHIFT))
48 #define WRITE_RADD_OFF(reg, radd_off) \
49 (reg = (reg & ~(ISPHIST_RADD_OFF_MASK)) \
50 | (radd_off << ISPHIST_RADD_OFF_SHIFT))
52 #define WRITE_BIT_SHIFT(reg, bit_shift) \
53 (reg = (reg & ~(ISPHIST_CNT_SHIFT_MASK)) \
54 | (bit_shift << ISPHIST_CNT_SHIFT_SHIFT))
56 #define WRITE_DATA_SIZE(reg, data_size) \
57 (reg = (reg & ~(ISPHIST_CNT_DATASIZE_MASK)) \
58 | (data_size << ISPHIST_CNT_DATASIZE_SHIFT))
60 #define WRITE_NUM_BINS(reg, num_bins) \
61 (reg = (reg & ~(ISPHIST_CNT_BINS_MASK)) \
62 | (num_bins << ISPHIST_CNT_BINS_SHIFT))
64 #define WRITE_WB_R(reg, reg_wb_gain) \
65 reg = ((reg & ~(ISPHIST_WB_GAIN_WG00_MASK)) \
66 | (reg_wb_gain << ISPHIST_WB_GAIN_WG00_SHIFT))
68 #define WRITE_WB_RG(reg, reg_wb_gain) \
69 (reg = (reg & ~(ISPHIST_WB_GAIN_WG01_MASK)) \
70 | (reg_wb_gain << ISPHIST_WB_GAIN_WG01_SHIFT))
72 #define WRITE_WB_B(reg, reg_wb_gain) \
73 (reg = (reg & ~(ISPHIST_WB_GAIN_WG02_MASK)) \
74 | (reg_wb_gain << ISPHIST_WB_GAIN_WG02_SHIFT))
76 #define WRITE_WB_BG(reg, reg_wb_gain) \
77 (reg = (reg & ~(ISPHIST_WB_GAIN_WG03_MASK)) \
78 | (reg_wb_gain << ISPHIST_WB_GAIN_WG03_SHIFT))
80 #define WRITE_REG_HORIZ(reg, reg_n_hor) \
81 (reg = ((reg & ~ISPHIST_REGHORIZ_MASK) \
82 | (reg_n_hor & ISPHIST_REGHORIZ_MASK)))
84 #define WRITE_REG_VERT(reg, reg_n_vert) \
85 (reg = ((reg & ~ISPHIST_REGVERT_MASK) \
86 | (reg_n_vert & ISPHIST_REGVERT_MASK)))
89 * struct isp_hist_regs - Current value of Histogram configuration registers.
90 * @pcr: Peripheral control register.
91 * @cnt: Histogram control register.
92 * @wb_gain: Histogram white balance gain register.
93 * @r0_h: Region 0 horizontal register.
94 * @r0_v: Region 0 vertical register.
95 * @r1_h: Region 1 horizontal register.
96 * @r1_v: Region 1 vertical register.
97 * @r2_h: Region 2 horizontal register.
98 * @r2_v: Region 2 vertical register.
99 * @r3_h: Region 3 horizontal register.
100 * @r3_v: Region 3 vertical register.
101 * @hist_addr: Histogram address register.
102 * @hist_data: Histogram data.
103 * @hist_radd: Address register. When input data comes from mem.
104 * @hist_radd_off: Address offset register. When input data comes from mem.
105 * @h_v_info: Image size register. When input data comes from mem.
107 struct isp_hist_regs
{
127 * struct isp_hist_status - Histogram status.
128 * @hist_enable: Enables the histogram module.
129 * @initialized: Flag to indicate that the module is correctly initializated.
130 * @frame_cnt: Actual frame count.
131 * @frame_req: Frame requested by user.
132 * @completed: Flag to indicate if a frame request is completed.
134 struct isp_hist_device
{
141 struct isp_hist_regs regs
;
145 void isp_hist_enable(struct isp_hist_device
*isp_hist
, u8 enable
);
147 int isp_hist_busy(struct isp_hist_device
*isp_hist
);
149 int isp_hist_configure(struct isp_hist_device
*isp_hist
,
150 struct isp_hist_config
*histcfg
);
152 int isp_hist_request_statistics(struct isp_hist_device
*isp_hist
,
153 struct isp_hist_data
*histdata
);
155 void isphist_save_context(struct device
*dev
);
157 void isp_hist_suspend(struct isp_hist_device
*isp_hist
);
159 void isp_hist_resume(struct isp_hist_device
*isp_hist
);
161 void isphist_restore_context(struct device
*dev
);
163 #endif /* OMAP_ISP_HIST */