2 * include/media/lm3554.h
4 * Copyright (c) 2010-2012 Intel Corporation. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <linux/videodev2.h>
25 #include <media/v4l2-subdev.h>
27 #define LM3554_NAME "lm3554"
28 #define LM3554_ID 3554
30 #define v4l2_queryctrl_entry_integer(_id, _name,\
31 _minimum, _maximum, _step, \
32 _default_value, _flags) \
35 .type = V4L2_CTRL_TYPE_INTEGER, \
37 .minimum = (_minimum), \
38 .maximum = (_maximum), \
40 .default_value = (_default_value),\
43 #define v4l2_queryctrl_entry_boolean(_id, _name,\
44 _default_value, _flags) \
47 .type = V4L2_CTRL_TYPE_BOOLEAN, \
52 .default_value = (_default_value),\
56 #define s_ctrl_id_entry_integer(_id, _name, \
57 _minimum, _maximum, _step, \
58 _default_value, _flags, \
61 .qc = v4l2_queryctrl_entry_integer(_id, _name,\
62 _minimum, _maximum, _step,\
63 _default_value, _flags), \
68 #define s_ctrl_id_entry_boolean(_id, _name, \
69 _default_value, _flags, \
72 .qc = v4l2_queryctrl_entry_boolean(_id, _name,\
73 _default_value, _flags), \
78 /* Value settings for Flash Time-out Duration*/
79 #define LM3554_DEFAULT_TIMEOUT 512U
80 #define LM3554_MIN_TIMEOUT 32U
81 #define LM3554_MAX_TIMEOUT 1024U
82 #define LM3554_TIMEOUT_STEPSIZE 32U
85 #define LM3554_MODE_SHUTDOWN 0
86 #define LM3554_MODE_INDICATOR 1
87 #define LM3554_MODE_TORCH 2
88 #define LM3554_MODE_FLASH 3
90 /* timer delay time */
91 #define LM3554_TIMER_DELAY 5
93 /* Percentage <-> value macros */
94 #define LM3554_MIN_PERCENT 0U
95 #define LM3554_MAX_PERCENT 100U
96 #define LM3554_CLAMP_PERCENTAGE(val) \
97 clamp(val, LM3554_MIN_PERCENT, LM3554_MAX_PERCENT)
99 #define LM3554_VALUE_TO_PERCENT(v, step) (((((unsigned long)(v))*(step))+50)/100)
100 #define LM3554_PERCENT_TO_VALUE(p, step) (((((unsigned long)(p))*100)+(step>>1))/(step))
102 /* Product specific limits
103 * TODO: get these from platform data */
104 #define LM3554_FLASH_MAX_LVL 0x0F /* 1191mA */
106 /* Flash brightness, input is percentage, output is [0..15] */
107 #define LM3554_FLASH_STEP \
108 ((100ul*(LM3554_MAX_PERCENT)+((LM3554_FLASH_MAX_LVL)>>1))/((LM3554_FLASH_MAX_LVL)))
109 #define LM3554_FLASH_DEFAULT_BRIGHTNESS \
110 LM3554_VALUE_TO_PERCENT(13, LM3554_FLASH_STEP)
112 /* Torch brightness, input is percentage, output is [0..7] */
113 #define LM3554_TORCH_STEP 1250
114 #define LM3554_TORCH_DEFAULT_BRIGHTNESS \
115 LM3554_VALUE_TO_PERCENT(2, LM3554_TORCH_STEP)
117 /* Indicator brightness, input is percentage, output is [0..3] */
118 #define LM3554_INDICATOR_STEP 2500
119 #define LM3554_INDICATOR_DEFAULT_BRIGHTNESS \
120 LM3554_VALUE_TO_PERCENT(1, LM3554_INDICATOR_STEP)
123 * lm3554_platform_data - Flash controller platform data
125 struct lm3554_platform_data {
130 unsigned int current_limit;
131 unsigned int envm_tx2;
132 unsigned int tx2_polarity;
135 #endif /* _LM3554_H_ */