29 #include <linux/device.h>
30 #include <linux/slab.h>
36 #define IS_OUT_OF_BOUNDS(value, min, max) \
37 (((value) < (min)) || ((value) > (max)))
39 static void h3a_af_setup_regs(
struct ispstat *af,
void *
priv)
63 pax1 |= (conf->
paxel.height >> 1) - 1;
72 pax2 |= (conf->
paxel.h_cnt - 1);
79 paxstart |= conf->
paxel.v_start;
84 isp_reg_writel(af->
isp, conf->
iir.h_start,
89 for (index = 0; index <= 8; index += 2) {
93 coef |= conf->
iir.coeff_set0[index + 1] <<
101 coef |= conf->
iir.coeff_set1[
index];
102 coef |= conf->
iir.coeff_set1[index + 1] <<
109 isp_reg_writel(af->
isp, conf->
iir.coeff_set0[10],
112 isp_reg_writel(af->
isp, conf->
iir.coeff_set1[10],
125 if (conf->
hmf.enable) {
154 static int h3a_af_busy(
struct ispstat *af)
166 static int h3a_af_validate_params(
struct ispstat *af,
void *new_conf)
194 paxel_cfg->
width % 2)
225 if ((paxel_cfg->
h_cnt * paxel_cfg->
v_cnt > 9) &&
229 buf_size = h3a_af_get_buf_size(user_cfg);
240 static void h3a_af_set_params(
struct ispstat *af,
void *new_conf)
254 if (cur_cfg->
hmf.enable != user_cfg->
hmf.enable) {
258 if (cur_cfg->
hmf.threshold != user_cfg->
hmf.threshold) {
270 if (cur_cfg->
iir.h_start != user_cfg->
iir.h_start) {
275 if (cur_cfg->
iir.coeff_set0[index] !=
276 user_cfg->
iir.coeff_set0[index]) {
280 if (cur_cfg->
iir.coeff_set1[index] !=
281 user_cfg->
iir.coeff_set1[index]) {
288 if ((cur_cfg->
paxel.width != user_cfg->
paxel.width) ||
289 (cur_cfg->
paxel.height != user_cfg->
paxel.height) ||
290 (cur_cfg->
paxel.h_start != user_cfg->
paxel.h_start) ||
291 (cur_cfg->
paxel.v_start != user_cfg->
paxel.v_start) ||
292 (cur_cfg->
paxel.h_cnt != user_cfg->
paxel.h_cnt) ||
293 (cur_cfg->
paxel.v_cnt != user_cfg->
paxel.v_cnt) ||
294 (cur_cfg->
paxel.line_inc != user_cfg->
paxel.line_inc)) {
305 memcpy(cur_cfg, user_cfg,
sizeof(*cur_cfg));
314 cur_cfg->
buf_size = h3a_af_get_buf_size(cur_cfg);
338 .validate_params = h3a_af_validate_params,
339 .set_params = h3a_af_set_params,
340 .setup_regs = h3a_af_setup_regs,
341 .enable = h3a_af_enable,
346 .ioctl = h3a_af_ioctl,
356 .core = &h3a_af_subdev_core_ops,
357 .video = &h3a_af_subdev_video_ops,
368 af_cfg = kzalloc(
sizeof(*af_cfg),
GFP_KERNEL);
372 memset(af, 0,
sizeof(*af));
373 af->
ops = &h3a_af_ops;
380 af_recover_cfg = kzalloc(
sizeof(*af_recover_cfg),
GFP_KERNEL);
381 if (!af_recover_cfg) {
382 dev_err(af->
isp->dev,
"AF: cannot allocate memory for recover "
385 goto err_recover_alloc;
394 if (h3a_af_validate_params(af, af_recover_cfg)) {
395 dev_err(af->
isp->dev,
"AF: recover configuration is "
401 af_recover_cfg->
buf_size = h3a_af_get_buf_size(af_recover_cfg);
411 kfree(af_recover_cfg);