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
{
50 struct v4l2_subdev sd
;
51 struct v4l2_ctrl_handler hdl
;
54 struct v4l2_ctrl
*volume
;
55 struct v4l2_ctrl
*mute
;
57 int pvr150_workaround
;
60 enum cx25840_video_input vid_input
;
61 enum cx25840_audio_input aud_input
;
65 enum cx25840_model id
;
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
];
77 static inline struct cx25840_state
*to_state(struct v4l2_subdev
*sd
)
79 return container_of(sd
, struct cx25840_state
, sd
);
82 static inline struct v4l2_subdev
*to_sd(struct v4l2_ctrl
*ctrl
)
84 return &container_of(ctrl
->handler
, struct cx25840_state
, hdl
)->sd
;
87 static inline bool is_cx2583x(struct cx25840_state
*state
)
89 return state
->id
== CX25836
||
93 static inline bool is_cx231xx(struct cx25840_state
*state
)
95 return state
->id
== CX2310X_AV
;
98 static inline bool is_cx2388x(struct cx25840_state
*state
)
100 return state
->id
== CX23885_AV
||
101 state
->id
== CX23887_AV
||
102 state
->id
== CX23888_AV
;
105 static inline bool is_cx23885(struct cx25840_state
*state
)
107 return state
->id
== CX23885_AV
;
110 static inline bool is_cx23887(struct cx25840_state
*state
)
112 return state
->id
== CX23887_AV
;
115 static inline bool is_cx23888(struct cx25840_state
*state
)
117 return state
->id
== CX23888_AV
;
120 /* ----------------------------------------------------------------------- */
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
,
129 void cx25840_std_setup(struct i2c_client
*client
);
131 /* ----------------------------------------------------------------------- */
132 /* cx25850-firmware.c */
133 int cx25840_loadfw(struct i2c_client
*client
);
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
);
140 extern const struct v4l2_ctrl_ops cx25840_audio_ctrl_ops
;
142 /* ----------------------------------------------------------------------- */
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
);
149 /* ----------------------------------------------------------------------- */
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
);