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
{
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
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
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
{
79 struct v4l2_subdev sd
;
80 struct v4l2_ctrl_handler hdl
;
83 struct v4l2_ctrl
*volume
;
84 struct v4l2_ctrl
*mute
;
86 int pvr150_workaround
;
89 enum cx25840_video_input vid_input
;
90 enum cx25840_audio_input aud_input
;
94 enum cx25840_model id
;
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
];
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 /* ----------------------------------------------------------------------- */
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
,
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 /* ----------------------------------------------------------------------- */
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 /* ----------------------------------------------------------------------- */
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
);