1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* cx25840 internal API header
4 * Copyright (C) 2003-2004 Chris Kennedy
7 #ifndef _CX25840_CORE_H_
8 #define _CX25840_CORE_H_
10 #include <linux/videodev2.h>
11 #include <media/v4l2-device.h>
12 #include <media/v4l2-ctrls.h>
13 #include <linux/i2c.h>
15 struct cx25840_ir_state
;
30 enum cx25840_media_pads
{
38 * struct cx25840_state - a device instance private data
39 * @c: i2c_client struct representing this device
40 * @sd: our V4L2 sub-device
41 * @hdl: our V4L2 control handler
42 * @volume: audio volume V4L2 control (non-cx2583x devices only)
43 * @mute: audio mute V4L2 control (non-cx2583x devices only)
44 * @pvr150_workaround: whether we enable workaround for Hauppauge PVR150
45 * hardware bug (audio dropping out)
46 * @generic_mode: whether we disable ivtv-specific hacks
47 * this mode gets turned on when the bridge driver calls
48 * cx25840 subdevice init core op
49 * @radio: set if we are currently in the radio mode, otherwise
50 * the current mode is non-radio (that is, video)
51 * @std: currently set video standard
52 * @vid_input: currently set video input
53 * @vid_config: currently set video output configuration
54 * only used in the generic mode
55 * @aud_input: currently set audio input
56 * @audclk_freq: currently set audio sample rate
57 * @audmode: currently set audio mode (when in non-radio mode)
58 * @vbi_line_offset: vbi line number offset
59 * @id: exact device model
60 * @rev: raw device id read from the chip
61 * @is_initialized: whether we have already loaded firmware into the chip
63 * @vbi_regs_offset: offset of vbi regs
64 * @fw_wait: wait queue to wake an initialization function up when
65 * firmware loading (on a separate workqueue) finishes
66 * @fw_work: a work that actually loads the firmware on a separate
68 * @ir_state: a pointer to chip IR controller private data
69 * @pads: array of supported chip pads (currently only a stub)
71 struct cx25840_state
{
73 struct v4l2_subdev sd
;
74 struct v4l2_ctrl_handler hdl
;
77 struct v4l2_ctrl
*volume
;
78 struct v4l2_ctrl
*mute
;
80 int pvr150_workaround
;
84 enum cx25840_video_input vid_input
;
86 enum cx25840_audio_input aud_input
;
90 enum cx25840_model id
;
93 unsigned int vbi_regs_offset
;
94 wait_queue_head_t fw_wait
;
95 struct work_struct fw_work
;
96 struct cx25840_ir_state
*ir_state
;
97 #if defined(CONFIG_MEDIA_CONTROLLER)
98 struct media_pad pads
[CX25840_NUM_PADS
];
102 static inline struct cx25840_state
*to_state(struct v4l2_subdev
*sd
)
104 return container_of(sd
, struct cx25840_state
, sd
);
107 static inline struct v4l2_subdev
*to_sd(struct v4l2_ctrl
*ctrl
)
109 return &container_of(ctrl
->handler
, struct cx25840_state
, hdl
)->sd
;
112 static inline bool is_cx2583x(struct cx25840_state
*state
)
114 return state
->id
== CX25836
||
115 state
->id
== CX25837
;
118 static inline bool is_cx2584x(struct cx25840_state
*state
)
120 return state
->id
== CX25840
||
121 state
->id
== CX25841
||
122 state
->id
== CX25842
||
123 state
->id
== CX25843
;
126 static inline bool is_cx231xx(struct cx25840_state
*state
)
128 return state
->id
== CX2310X_AV
;
131 static inline bool is_cx2388x(struct cx25840_state
*state
)
133 return state
->id
== CX23885_AV
||
134 state
->id
== CX23887_AV
||
135 state
->id
== CX23888_AV
;
138 static inline bool is_cx23885(struct cx25840_state
*state
)
140 return state
->id
== CX23885_AV
;
143 static inline bool is_cx23887(struct cx25840_state
*state
)
145 return state
->id
== CX23887_AV
;
148 static inline bool is_cx23888(struct cx25840_state
*state
)
150 return state
->id
== CX23888_AV
;
153 /* ----------------------------------------------------------------------- */
155 int cx25840_write(struct i2c_client
*client
, u16 addr
, u8 value
);
156 int cx25840_write4(struct i2c_client
*client
, u16 addr
, u32 value
);
157 u8
cx25840_read(struct i2c_client
*client
, u16 addr
);
158 u32
cx25840_read4(struct i2c_client
*client
, u16 addr
);
159 int cx25840_and_or(struct i2c_client
*client
, u16 addr
, unsigned int mask
,
161 int cx25840_and_or4(struct i2c_client
*client
, u16 addr
, u32 and_mask
,
163 void cx25840_std_setup(struct i2c_client
*client
);
165 /* ----------------------------------------------------------------------- */
166 /* cx25850-firmware.c */
167 int cx25840_loadfw(struct i2c_client
*client
);
169 /* ----------------------------------------------------------------------- */
170 /* cx25850-audio.c */
171 void cx25840_audio_set_path(struct i2c_client
*client
);
172 int cx25840_s_clock_freq(struct v4l2_subdev
*sd
, u32 freq
);
174 extern const struct v4l2_ctrl_ops cx25840_audio_ctrl_ops
;
176 /* ----------------------------------------------------------------------- */
178 int cx25840_s_raw_fmt(struct v4l2_subdev
*sd
, struct v4l2_vbi_format
*fmt
);
179 int cx25840_s_sliced_fmt(struct v4l2_subdev
*sd
,
180 struct v4l2_sliced_vbi_format
*fmt
);
181 int cx25840_g_sliced_fmt(struct v4l2_subdev
*sd
,
182 struct v4l2_sliced_vbi_format
*fmt
);
183 int cx25840_decode_vbi_line(struct v4l2_subdev
*sd
,
184 struct v4l2_decode_vbi_line
*vbi
);
186 /* ----------------------------------------------------------------------- */
188 extern const struct v4l2_subdev_ir_ops cx25840_ir_ops
;
189 int cx25840_ir_log_status(struct v4l2_subdev
*sd
);
190 int cx25840_ir_irq_handler(struct v4l2_subdev
*sd
, u32 status
, bool *handled
);
191 int cx25840_ir_probe(struct v4l2_subdev
*sd
);
192 int cx25840_ir_remove(struct v4l2_subdev
*sd
);