]>
Commit | Line | Data |
---|---|---|
31bc09b5 | 1 | /* cx25840 internal API header |
bd985160 HV |
2 | * |
3 | * Copyright (C) 2003-2004 Chris Kennedy | |
4 | * | |
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. | |
9 | * | |
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. | |
bd985160 HV |
14 | */ |
15 | ||
31bc09b5 HV |
16 | #ifndef _CX25840_CORE_H_ |
17 | #define _CX25840_CORE_H_ | |
bd985160 | 18 | |
cab462f7 | 19 | |
bd985160 | 20 | #include <linux/videodev2.h> |
9357b31c | 21 | #include <media/v4l2-device.h> |
e34e658b | 22 | #include <media/v4l2-ctrls.h> |
bd985160 HV |
23 | #include <linux/i2c.h> |
24 | ||
52fd3dda AW |
25 | struct cx25840_ir_state; |
26 | ||
29d6a98b HV |
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, | |
38 | }; | |
39 | ||
7e4f23d5 MCC |
40 | enum cx25840_media_pads { |
41 | CX25840_PAD_INPUT, | |
42 | CX25840_PAD_VID_OUT, | |
43 | CX25840_PAD_VBI_OUT, | |
44 | ||
45 | CX25840_NUM_PADS | |
46 | }; | |
47 | ||
bd985160 | 48 | struct cx25840_state { |
21340ae0 | 49 | struct i2c_client *c; |
9357b31c | 50 | struct v4l2_subdev sd; |
e34e658b HV |
51 | struct v4l2_ctrl_handler hdl; |
52 | struct { | |
53 | /* volume cluster */ | |
54 | struct v4l2_ctrl *volume; | |
55 | struct v4l2_ctrl *mute; | |
56 | }; | |
a8bbf12a | 57 | int pvr150_workaround; |
3faeeae4 | 58 | int radio; |
081b496a | 59 | v4l2_std_id std; |
a8bbf12a HV |
60 | enum cx25840_video_input vid_input; |
61 | enum cx25840_audio_input aud_input; | |
3578d3dd | 62 | u32 audclk_freq; |
8a4b275f | 63 | int audmode; |
3e3bf277 | 64 | int vbi_line_offset; |
29d6a98b | 65 | enum cx25840_model id; |
3434eb7e | 66 | u32 rev; |
c976bc82 | 67 | int is_initialized; |
cdf472d3 | 68 | unsigned vbi_regs_offset; |
21340ae0 HV |
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 */ | |
52fd3dda | 71 | struct cx25840_ir_state *ir_state; |
8cd61969 | 72 | #if defined(CONFIG_MEDIA_CONTROLLER) |
7e4f23d5 | 73 | struct media_pad pads[CX25840_NUM_PADS]; |
8cd61969 | 74 | #endif |
bd985160 HV |
75 | }; |
76 | ||
9357b31c HV |
77 | static inline struct cx25840_state *to_state(struct v4l2_subdev *sd) |
78 | { | |
79 | return container_of(sd, struct cx25840_state, sd); | |
80 | } | |
81 | ||
e34e658b HV |
82 | static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) |
83 | { | |
84 | return &container_of(ctrl->handler, struct cx25840_state, hdl)->sd; | |
85 | } | |
86 | ||
2a03f034 AW |
87 | static inline bool is_cx2583x(struct cx25840_state *state) |
88 | { | |
29d6a98b HV |
89 | return state->id == CX25836 || |
90 | state->id == CX25837; | |
2a03f034 AW |
91 | } |
92 | ||
93 | static inline bool is_cx231xx(struct cx25840_state *state) | |
94 | { | |
29d6a98b | 95 | return state->id == CX2310X_AV; |
2a03f034 AW |
96 | } |
97 | ||
98 | static inline bool is_cx2388x(struct cx25840_state *state) | |
99 | { | |
29d6a98b HV |
100 | return state->id == CX23885_AV || |
101 | state->id == CX23887_AV || | |
102 | state->id == CX23888_AV; | |
2a03f034 AW |
103 | } |
104 | ||
52fd3dda AW |
105 | static inline bool is_cx23885(struct cx25840_state *state) |
106 | { | |
29d6a98b | 107 | return state->id == CX23885_AV; |
52fd3dda AW |
108 | } |
109 | ||
110 | static inline bool is_cx23887(struct cx25840_state *state) | |
111 | { | |
29d6a98b | 112 | return state->id == CX23887_AV; |
52fd3dda AW |
113 | } |
114 | ||
115 | static inline bool is_cx23888(struct cx25840_state *state) | |
116 | { | |
29d6a98b | 117 | return state->id == CX23888_AV; |
52fd3dda AW |
118 | } |
119 | ||
bd985160 HV |
120 | /* ----------------------------------------------------------------------- */ |
121 | /* cx25850-core.c */ | |
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); | |
e2b8cf4c | 126 | int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value); |
52fd3dda AW |
127 | int cx25840_and_or4(struct i2c_client *client, u16 addr, u32 and_mask, |
128 | u32 or_value); | |
cb5aa1c6 | 129 | void cx25840_std_setup(struct i2c_client *client); |
bd985160 HV |
130 | |
131 | /* ----------------------------------------------------------------------- */ | |
132 | /* cx25850-firmware.c */ | |
133 | int cx25840_loadfw(struct i2c_client *client); | |
134 | ||
135 | /* ----------------------------------------------------------------------- */ | |
136 | /* cx25850-audio.c */ | |
a8bbf12a | 137 | void cx25840_audio_set_path(struct i2c_client *client); |
df1d5ed8 | 138 | int cx25840_s_clock_freq(struct v4l2_subdev *sd, u32 freq); |
e34e658b HV |
139 | |
140 | extern const struct v4l2_ctrl_ops cx25840_audio_ctrl_ops; | |
bd985160 HV |
141 | |
142 | /* ----------------------------------------------------------------------- */ | |
143 | /* cx25850-vbi.c */ | |
5393db43 HV |
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); | |
df1d5ed8 | 147 | int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi); |
bd985160 | 148 | |
52fd3dda AW |
149 | /* ----------------------------------------------------------------------- */ |
150 | /* cx25850-ir.c */ | |
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); | |
156 | ||
bd985160 | 157 | #endif |