summaryrefstree
path: root/kernel/drivers/media/platform/exynos/camera-pp/camerapp-sfr-api-common.h
blob: 3bf753f432b991f5685381d0ea7816533d45e439 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Samsung EXYNOS Camera PostProcessing driver
 *
 * Copyright (C) 2014 Samsung Electronics Co., Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef CAMERAPP_SFR_API_COMMON_H
#define CAMERAPP_SFR_API_COMMON_H

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/slab.h>

extern int camerapp_log_level;
#define camerapp_dbg(fmt, args...)						\
	do {								\
		if (camerapp_log_level)					\
			pr_info("[%s:%d] "				\
			fmt, __func__, __LINE__, ##args);		\
	} while (0)

#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))

enum  regdata_type {
	/* read write */
	RW			= 0,
	/* read only */
	RO			= 1,
	/* write only */
	WO			= 2,
	/* write input */
	WI			= 2,
	/* clear after read */
	RAC			= 3,
	/* write 1 -> clear */
	W1C			= 4,
	/* write read input */
	WRI			= 5,
	/* write input */
	RWI			= 5,
	/* only scaler */
	R_W			= 6,
	/* read & write for clear */
	RWC			= 7,
	/* read & write as dual setting */
	RWS			= 8,
	/* write only*/
	RIW			= 9,
	/* read only latched implementation register */
	ROL			= 10,
};

struct camerapp_sfr_reg {
	unsigned int	 sfr_offset;
	char		 *reg_name;
};

struct camerapp_sfr_field {
	char			*field_name;
	unsigned int		bit_start;
	unsigned int		bit_width;
	enum regdata_type	type;
	int			reset;
};

u32 camerapp_sfr_get_reg(void __iomem *base_addr, const struct camerapp_sfr_reg *reg);
void camerapp_sfr_set_reg(void __iomem *base_addr, const struct camerapp_sfr_reg *reg, u32 val);
u32 camerapp_sfr_get_field(void __iomem *base_addr, const struct camerapp_sfr_reg *reg, const struct camerapp_sfr_field *field);
void camerapp_sfr_set_field(void __iomem *base_addr, const struct camerapp_sfr_reg *reg, const struct camerapp_sfr_field *field, u32 val);
u32 camerapp_sfr_get_field_value(u32 reg_value, const struct camerapp_sfr_field *field);
u32 camerapp_sfr_set_field_value(u32 reg_value, const struct camerapp_sfr_field *field, u32 val);
void camerapp_sfr_dump_regs(void __iomem *base_addr, const struct camerapp_sfr_reg *regs, u32 total_cnt);
#endif