perf tools: Don't clone maps from parent when synthesizing forks
[linux/fpc-iii.git] / drivers / media / i2c / cx25840 / cx25840-core.h
blobc323b1af1f8357d3ca3e672df9ed5784ac131c23
1 /* cx25840 internal API header
3 * Copyright (C) 2003-2004 Chris Kennedy
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.
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.
16 #ifndef _CX25840_CORE_H_
17 #define _CX25840_CORE_H_
20 #include <linux/videodev2.h>
21 #include <media/v4l2-device.h>
22 #include <media/v4l2-ctrls.h>
23 #include <linux/i2c.h>
25 struct cx25840_ir_state;
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,
40 enum cx25840_media_pads {
41 CX25840_PAD_INPUT,
42 CX25840_PAD_VID_OUT,
43 CX25840_PAD_VBI_OUT,
45 CX25840_NUM_PADS
48 /**
49 * struct cx25840_state - a device instance private data
50 * @c: i2c_client struct representing this device
51 * @sd: our V4L2 sub-device
52 * @hdl: our V4L2 control handler
53 * @volume: audio volume V4L2 control (non-cx2583x devices only)
54 * @mute: audio mute V4L2 control (non-cx2583x devices only)
55 * @pvr150_workaround: whether we enable workaround for Hauppauge PVR150
56 * hardware bug (audio dropping out)
57 * @radio: set if we are currently in the radio mode, otherwise
58 * the current mode is non-radio (that is, video)
59 * @std: currently set video standard
60 * @vid_input: currently set video input
61 * @aud_input: currently set audio input
62 * @audclk_freq: currently set audio sample rate
63 * @audmode: currently set audio mode (when in non-radio mode)
64 * @vbi_line_offset: vbi line number offset
65 * @id: exact device model
66 * @rev: raw device id read from the chip
67 * @is_initialized: whether we have already loaded firmware into the chip
68 * and initialized it
69 * @vbi_regs_offset: offset of vbi regs
70 * @fw_wait: wait queue to wake an initalization function up when
71 * firmware loading (on a separate workqueue) finishes
72 * @fw_work: a work that actually loads the firmware on a separate
73 * workqueue
74 * @ir_state: a pointer to chip IR controller private data
75 * @pads: array of supported chip pads (currently only a stub)
77 struct cx25840_state {
78 struct i2c_client *c;
79 struct v4l2_subdev sd;
80 struct v4l2_ctrl_handler hdl;
81 struct {
82 /* volume cluster */
83 struct v4l2_ctrl *volume;
84 struct v4l2_ctrl *mute;
86 int pvr150_workaround;
87 int radio;
88 v4l2_std_id std;
89 enum cx25840_video_input vid_input;
90 enum cx25840_audio_input aud_input;
91 u32 audclk_freq;
92 int audmode;
93 int vbi_line_offset;
94 enum cx25840_model id;
95 u32 rev;
96 int is_initialized;
97 unsigned vbi_regs_offset;
98 wait_queue_head_t fw_wait;
99 struct work_struct fw_work;
100 struct cx25840_ir_state *ir_state;
101 #if defined(CONFIG_MEDIA_CONTROLLER)
102 struct media_pad pads[CX25840_NUM_PADS];
103 #endif
106 static inline struct cx25840_state *to_state(struct v4l2_subdev *sd)
108 return container_of(sd, struct cx25840_state, sd);
111 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
113 return &container_of(ctrl->handler, struct cx25840_state, hdl)->sd;
116 static inline bool is_cx2583x(struct cx25840_state *state)
118 return state->id == CX25836 ||
119 state->id == CX25837;
122 static inline bool is_cx231xx(struct cx25840_state *state)
124 return state->id == CX2310X_AV;
127 static inline bool is_cx2388x(struct cx25840_state *state)
129 return state->id == CX23885_AV ||
130 state->id == CX23887_AV ||
131 state->id == CX23888_AV;
134 static inline bool is_cx23885(struct cx25840_state *state)
136 return state->id == CX23885_AV;
139 static inline bool is_cx23887(struct cx25840_state *state)
141 return state->id == CX23887_AV;
144 static inline bool is_cx23888(struct cx25840_state *state)
146 return state->id == CX23888_AV;
149 /* ----------------------------------------------------------------------- */
150 /* cx25850-core.c */
151 int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
152 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value);
153 u8 cx25840_read(struct i2c_client *client, u16 addr);
154 u32 cx25840_read4(struct i2c_client *client, u16 addr);
155 int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value);
156 int cx25840_and_or4(struct i2c_client *client, u16 addr, u32 and_mask,
157 u32 or_value);
158 void cx25840_std_setup(struct i2c_client *client);
160 /* ----------------------------------------------------------------------- */
161 /* cx25850-firmware.c */
162 int cx25840_loadfw(struct i2c_client *client);
164 /* ----------------------------------------------------------------------- */
165 /* cx25850-audio.c */
166 void cx25840_audio_set_path(struct i2c_client *client);
167 int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
169 extern const struct v4l2_ctrl_ops cx25840_audio_ctrl_ops;
171 /* ----------------------------------------------------------------------- */
172 /* cx25850-vbi.c */
173 int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
174 int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
175 int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
176 int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi);
178 /* ----------------------------------------------------------------------- */
179 /* cx25850-ir.c */
180 extern const struct v4l2_subdev_ir_ops cx25840_ir_ops;
181 int cx25840_ir_log_status(struct v4l2_subdev *sd);
182 int cx25840_ir_irq_handler(struct v4l2_subdev *sd, u32 status, bool *handled);
183 int cx25840_ir_probe(struct v4l2_subdev *sd);
184 int cx25840_ir_remove(struct v4l2_subdev *sd);
186 #endif