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;
40 enum cx25840_media_pads {
48 * struct cx25840_state - a device instance private data
49 * @c: i2c_client struct representing this device
50 * @sd: our V4L2 sub-device
51 * @hdl: our V4L2 control handler
52 * @volume: audio volume V4L2 control (non-cx2583x devices only)
53 * @mute: audio mute V4L2 control (non-cx2583x devices only)
54 * @pvr150_workaround: whether we enable workaround for Hauppauge PVR150
55 * hardware bug (audio dropping out)
56 * @radio: set if we are currently in the radio mode, otherwise
57 * the current mode is non-radio (that is, video)
58 * @std: currently set video standard
59 * @vid_input: currently set video input
60 * @aud_input: currently set audio input
61 * @audclk_freq: currently set audio sample rate
62 * @audmode: currently set audio mode (when in non-radio mode)
63 * @vbi_line_offset: vbi line number offset
64 * @id: exact device model
65 * @rev: raw device id read from the chip
66 * @is_initialized: whether we have already loaded firmware into the chip
68 * @vbi_regs_offset: offset of vbi regs
69 * @fw_wait: wait queue to wake an initialization function up when
70 * firmware loading (on a separate workqueue) finishes
71 * @fw_work: a work that actually loads the firmware on a separate
73 * @ir_state: a pointer to chip IR controller private data
74 * @pads: array of supported chip pads (currently only a stub)
76 struct cx25840_state {
78 struct v4l2_subdev sd;
79 struct v4l2_ctrl_handler hdl;
82 struct v4l2_ctrl *volume;
83 struct v4l2_ctrl *mute;
85 int pvr150_workaround;
88 enum cx25840_video_input vid_input;
89 enum cx25840_audio_input aud_input;
93 enum cx25840_model id;
96 unsigned vbi_regs_offset;
97 wait_queue_head_t fw_wait;
98 struct work_struct fw_work;
99 struct cx25840_ir_state *ir_state;
100 #if defined(CONFIG_MEDIA_CONTROLLER)
101 struct media_pad pads[CX25840_NUM_PADS];
105 static inline struct cx25840_state *to_state(struct v4l2_subdev *sd)
107 return container_of(sd, struct cx25840_state, sd);
110 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
112 return &container_of(ctrl->handler, struct cx25840_state, hdl)->sd;
115 static inline bool is_cx2583x(struct cx25840_state *state)
117 return state->id == CX25836 ||
118 state->id == CX25837;
121 static inline bool is_cx231xx(struct cx25840_state *state)
123 return state->id == CX2310X_AV;
126 static inline bool is_cx2388x(struct cx25840_state *state)
128 return state->id == CX23885_AV ||
129 state->id == CX23887_AV ||
130 state->id == CX23888_AV;
133 static inline bool is_cx23885(struct cx25840_state *state)
135 return state->id == CX23885_AV;
138 static inline bool is_cx23887(struct cx25840_state *state)
140 return state->id == CX23887_AV;
143 static inline bool is_cx23888(struct cx25840_state *state)
145 return state->id == CX23888_AV;
148 /* ----------------------------------------------------------------------- */
150 int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
151 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value);
152 u8 cx25840_read(struct i2c_client *client, u16 addr);
153 u32 cx25840_read4(struct i2c_client *client, u16 addr);
154 int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value);
155 int cx25840_and_or4(struct i2c_client *client, u16 addr, u32 and_mask,
157 void cx25840_std_setup(struct i2c_client *client);
159 /* ----------------------------------------------------------------------- */
160 /* cx25850-firmware.c */
161 int cx25840_loadfw(struct i2c_client *client);
163 /* ----------------------------------------------------------------------- */
164 /* cx25850-audio.c */
165 void cx25840_audio_set_path(struct i2c_client *client);
166 int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq);
168 extern const struct v4l2_ctrl_ops cx25840_audio_ctrl_ops;
170 /* ----------------------------------------------------------------------- */
172 int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt);
173 int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
174 int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt);
175 int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi);
177 /* ----------------------------------------------------------------------- */
179 extern const struct v4l2_subdev_ir_ops cx25840_ir_ops;
180 int cx25840_ir_log_status(struct v4l2_subdev *sd);
181 int cx25840_ir_irq_handler(struct v4l2_subdev *sd, u32 status, bool *handled);
182 int cx25840_ir_probe(struct v4l2_subdev *sd);
183 int cx25840_ir_remove(struct v4l2_subdev *sd);