]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator. It includes the...
[mirror_ubuntu-artful-kernel.git] / drivers / media / dvb-frontends / cxd2880 / cxd2880_common.h
1 /*
2 * cxd2880_common.h
3 * Sony CXD2880 DVB-T2/T tuner + demodulator driver common definitions
4 *
5 * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; version 2 of the License.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, see <http://www.gnu.org/licenses/>.
24 */
25
26 #ifndef CXD2880_COMMON_H
27 #define CXD2880_COMMON_H
28
29 #include <linux/types.h>
30
31 #ifndef NULL
32 #ifdef __cplusplus
33 #define NULL 0
34 #else
35 #define NULL ((void *)0)
36 #endif
37 #endif
38
39 #include <linux/delay.h>
40 #define CXD2880_SLEEP(n) msleep(n)
41 #ifndef CXD2880_SLEEP_IN_MON
42 #define CXD2880_SLEEP_IN_MON(n, obj) CXD2880_SLEEP(n)
43 #endif
44
45 #define CXD2880_ARG_UNUSED(arg) ((void)(arg))
46
47 enum cxd2880_ret {
48 CXD2880_RESULT_OK,
49 CXD2880_RESULT_ERROR_ARG,
50 CXD2880_RESULT_ERROR_IO,
51 CXD2880_RESULT_ERROR_SW_STATE,
52 CXD2880_RESULT_ERROR_HW_STATE,
53 CXD2880_RESULT_ERROR_TIMEOUT,
54 CXD2880_RESULT_ERROR_UNLOCK,
55 CXD2880_RESULT_ERROR_RANGE,
56 CXD2880_RESULT_ERROR_NOSUPPORT,
57 CXD2880_RESULT_ERROR_CANCEL,
58 CXD2880_RESULT_ERROR_OTHER,
59 CXD2880_RESULT_ERROR_OVERFLOW,
60 CXD2880_RESULT_OK_CONFIRM
61 };
62
63 int cxd2880_convert2s_complement(u32 value, u32 bitlen);
64
65 u32 cxd2880_bit_split_from_byte_array(u8 *array, u32 start_bit, u32 bit_num);
66
67 struct cxd2880_atomic {
68 int counter;
69 };
70
71 #define cxd2880_atomic_set(a, i) ((a)->counter = i)
72 #define cxd2880_atomic_read(a) ((a)->counter)
73
74 struct cxd2880_stopwatch {
75 u32 start_time;
76 };
77
78 enum cxd2880_ret cxd2880_stopwatch_start(struct cxd2880_stopwatch *stopwatch);
79
80 enum cxd2880_ret cxd2880_stopwatch_sleep(struct cxd2880_stopwatch *stopwatch,
81 u32 ms);
82
83 enum cxd2880_ret cxd2880_stopwatch_elapsed(struct cxd2880_stopwatch *stopwatch,
84 u32 *elapsed);
85
86 #endif