]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/media/i2c/cx25840/cx25840-core.h
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / media / i2c / cx25840 / cx25840-core.h
1 /* cx25840 internal API header
2 *
3 * Copyright (C) 2003-2004 Chris Kennedy
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
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.
14 */
15
16 #ifndef _CX25840_CORE_H_
17 #define _CX25840_CORE_H_
18
19
20 #include <linux/videodev2.h>
21 #include <media/v4l2-device.h>
22 #include <media/v4l2-ctrls.h>
23 #include <linux/i2c.h>
24
25 struct cx25840_ir_state;
26
27 enum cx25840_model {
28 CX23885_AV,
29 CX23887_AV,
30 CX23888_AV,
31 CX2310X_AV,
32 CX25840,
33 CX25841,
34 CX25842,
35 CX25843,
36 CX25836,
37 CX25837,
38 };
39
40 enum cx25840_media_pads {
41 CX25840_PAD_INPUT,
42 CX25840_PAD_VID_OUT,
43 CX25840_PAD_VBI_OUT,
44
45 CX25840_NUM_PADS
46 };
47
48 struct cx25840_state {
49 struct i2c_client *c;
50 struct v4l2_subdev sd;
51 struct v4l2_ctrl_handler hdl;
52 struct {
53 /* volume cluster */
54 struct v4l2_ctrl *volume;
55 struct v4l2_ctrl *mute;
56 };
57 int pvr150_workaround;
58 int radio;
59 v4l2_std_id std;
60 enum cx25840_video_input vid_input;
61 enum cx25840_audio_input aud_input;
62 u32 audclk_freq;
63 int audmode;
64 int vbi_line_offset;
65 enum cx25840_model id;
66 u32 rev;
67 int is_initialized;
68 unsigned vbi_regs_offset;
69 wait_queue_head_t fw_wait; /* wake up when the fw load is finished */
70 struct work_struct fw_work; /* work entry for fw load */
71 struct cx25840_ir_state *ir_state;
72 #if defined(CONFIG_MEDIA_CONTROLLER)
73 struct media_pad pads[CX25840_NUM_PADS];
74 #endif
75 };
76
77 static inline struct cx25840_state *to_state(struct v4l2_subdev *sd)
78 {
79 return container_of(sd, struct cx25840_state, sd);
80 }
81
82 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
83 {
84 return &container_of(ctrl->handler, struct cx25840_state, hdl)->sd;
85 }
86
87 static inline bool is_cx2583x(struct cx25840_state *state)
88 {
89 return state->id == CX25836 ||
90 state->id == CX25837;
91 }
92
93 static inline bool is_cx231xx(struct cx25840_state *state)
94 {
95 return state->id == CX2310X_AV;
96 }
97
98 static inline bool is_cx2388x(struct cx25840_state *state)
99 {
100 return state->id == CX23885_AV ||
101 state->id == CX23887_AV ||
102 state->id == CX23888_AV;
103 }
104
105 static inline bool is_cx23885(struct cx25840_state *state)
106 {
107 return state->id == CX23885_AV;
108 }
109
110 static inline bool is_cx23887(struct cx25840_state *state)
111 {
112 return state->id == CX23887_AV;
113 }
114
115 static inline bool is_cx23888(struct cx25840_state *state)
116 {
117 return state->id == CX23888_AV;
118 }
119
120 /* ----------------------------------------------------------------------- */
121 /* cx25850-core.c */
122 int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
123 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value);
124 u8 cx25840_read(struct i2c_client *client, u16 addr);
125 u32 cx25840_read4(struct i2c_client *client, u16 addr);
126 int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value);
127 int cx25840_and_or4(struct i2c_client *client, u16 addr, u32 and_mask,
128 u32 or_value);
129 void cx25840_std_setup(struct i2c_client *client);
130
131 /* ----------------------------------------------------------------------- */
132 /* cx25850-firmware.c */
133 int cx25840_loadfw(struct i2c_client *client);
134
135 /* ----------------------------------------------------------------------- */
136 /* cx25850-audio.c */
137 void cx25840_audio_set_path(struct i2c_client *client);
138 int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
139
140 extern const struct v4l2_ctrl_ops cx25840_audio_ctrl_ops;
141
142 /* ----------------------------------------------------------------------- */
143 /* cx25850-vbi.c */
144 int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
145 int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
146 int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
147 int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi);
148
149 /* ----------------------------------------------------------------------- */
150 /* cx25850-ir.c */
151 extern const struct v4l2_subdev_ir_ops cx25840_ir_ops;
152 int cx25840_ir_log_status(struct v4l2_subdev *sd);
153 int cx25840_ir_irq_handler(struct v4l2_subdev *sd, u32 status, bool *handled);
154 int cx25840_ir_probe(struct v4l2_subdev *sd);
155 int cx25840_ir_remove(struct v4l2_subdev *sd);
156
157 #endif