Commit ff2a2001 authored by Andy Walls's avatar Andy Walls Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (10758): cx18: Convert I2C devices to v4l2_subdevices



This is a major perturbation to cx18 I2C device handling to convert it to the
v4l2_device/subdeivce framework.  This change breaks GPIO audio multiplexer
control for the time being.  It will be fixed in a coming change.

Signed-off-by: default avatarAndy Walls <awalls@radix.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent fa3e7036
Loading
Loading
Loading
Loading
+13 −37
Original line number Diff line number Diff line
@@ -23,9 +23,7 @@

#include "cx18-driver.h"
#include "cx18-io.h"
#include "cx18-i2c.h"
#include "cx18-cards.h"
#include "cx18-audio.h"

#define CX18_AUDIO_ENABLE 0xc72014

@@ -33,54 +31,32 @@
   settings. */
int cx18_audio_set_io(struct cx18 *cx)
{
	const struct cx18_card_audio_input *in;
	struct v4l2_routing route;
	u32 audio_input;
	u32 val;
	int mux_input;
	int err;

	/* Determine which input to use */
	if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) {
		audio_input = cx->card->radio_input.audio_input;
		mux_input = cx->card->radio_input.muxer_input;
	} else {
		audio_input =
			cx->card->audio_inputs[cx->audio_input].audio_input;
		mux_input =
			cx->card->audio_inputs[cx->audio_input].muxer_input;
	}
	if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags))
		in = &cx->card->radio_input;
	else
		in = &cx->card->audio_inputs[cx->audio_input];

	/* handle muxer chips */
	route.input = mux_input;
	route.input = in->muxer_input;
	route.output = 0;
	cx18_i2c_hw(cx, cx->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route);
	v4l2_subdev_call(cx->sd_extmux, audio, s_routing, &route);

	route.input = audio_input;
	err = cx18_i2c_hw(cx, cx->card->hw_audio_ctrl,
			VIDIOC_INT_S_AUDIO_ROUTING, &route);
	route.input = in->audio_input;
	err = cx18_call_hw_err(cx, cx->card->hw_audio_ctrl,
			       audio, s_routing, &route);
	if (err)
		return err;

	/* FIXME - this internal mux should be abstracted to a subdev */
	val = cx18_read_reg(cx, CX18_AUDIO_ENABLE) & ~0x30;
	val |= (audio_input > CX18_AV_AUDIO_SERIAL2) ? 0x20 :
					(audio_input << 4);
	val |= (in->audio_input > CX18_AV_AUDIO_SERIAL2) ? 0x20 :
					(in->audio_input << 4);
	cx18_write_reg_expect(cx, val | 0xb00, CX18_AUDIO_ENABLE, val, 0x30);
	return 0;
}

void cx18_audio_set_route(struct cx18 *cx, struct v4l2_routing *route)
{
	cx18_i2c_hw(cx, cx->card->hw_audio_ctrl,
			VIDIOC_INT_S_AUDIO_ROUTING, route);
}

void cx18_audio_set_audio_clock_freq(struct cx18 *cx, u8 freq)
{
	static u32 freqs[3] = { 44100, 48000, 32000 };

	/* The audio clock of the digitizer must match the codec sample
	   rate otherwise you get some very strange effects. */
	if (freq > 2)
		return;
	cx18_call_i2c_clients(cx, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[freq]);
}
+0 −2
Original line number Diff line number Diff line
@@ -22,5 +22,3 @@
 */

int cx18_audio_set_io(struct cx18 *cx);
void cx18_audio_set_route(struct cx18 *cx, struct v4l2_routing *route);
void cx18_audio_set_audio_clock_freq(struct cx18 *cx, u8 freq);
+8 −7
Original line number Diff line number Diff line
@@ -1209,9 +1209,10 @@ static const struct v4l2_subdev_ops cx18_av_ops = {
	.video = &cx18_av_video_ops,
};

int cx18_av_probe(struct cx18 *cx, struct v4l2_subdev **sd)
int cx18_av_probe(struct cx18 *cx)
{
	struct cx18_av_state *state = &cx->av_state;
	struct v4l2_subdev *sd;

	state->rev = cx18_av_read4(cx, CXADEC_CHIP_CTRL) & 0xffff;
	state->id = ((state->rev >> 4) == CXADEC_CHIP_TYPE_MAKO)
@@ -1224,13 +1225,13 @@ int cx18_av_probe(struct cx18 *cx, struct v4l2_subdev **sd)
	state->slicer_line_delay = 0;
	state->slicer_line_offset = (10 + state->slicer_line_delay - 2);

	*sd = &state->sd;
	v4l2_subdev_init(*sd, &cx18_av_ops);
	v4l2_set_subdevdata(*sd, cx);
	snprintf((*sd)->name, sizeof((*sd)->name),
	sd = &state->sd;
	v4l2_subdev_init(sd, &cx18_av_ops);
	v4l2_set_subdevdata(sd, cx);
	snprintf(sd->name, sizeof(sd->name),
		 "%s internal A/V decoder", cx->v4l2_dev.name);
	(*sd)->grp_id = CX18_HW_CX23418;
	return v4l2_device_register_subdev(&cx->v4l2_dev, *sd);
	sd->grp_id = CX18_HW_418_AV;
	return v4l2_device_register_subdev(&cx->v4l2_dev, sd);
}

void cx18_av_exit(struct cx18 *cx, struct v4l2_subdev *sd)
+1 −1
Original line number Diff line number Diff line
@@ -342,7 +342,7 @@ int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value);
int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value);
void cx18_av_std_setup(struct cx18 *cx);

int cx18_av_probe(struct cx18 *cx, struct v4l2_subdev **sd);
int cx18_av_probe(struct cx18 *cx);
void cx18_av_exit(struct cx18 *cx, struct v4l2_subdev *sd);

/* ----------------------------------------------------------------------- */
+16 −16
Original line number Diff line number Diff line
@@ -53,9 +53,9 @@ static const struct cx18_card cx18_card_hvr1600_esmt = {
	.name = "Hauppauge HVR-1600",
	.comment = "Simultaneous Digital and Analog TV capture supported\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_muxer = CX18_HW_CS5345,
	.hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
		  CX18_HW_CS5345 | CX18_HW_DVB,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
@@ -99,9 +99,9 @@ static const struct cx18_card cx18_card_hvr1600_samsung = {
	.name = "Hauppauge HVR-1600 (Preproduction)",
	.comment = "Simultaneous Digital and Analog TV capture supported\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_muxer = CX18_HW_CS5345,
	.hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
	.hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
		  CX18_HW_CS5345 | CX18_HW_DVB,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
@@ -154,8 +154,8 @@ static const struct cx18_card cx18_card_h900 = {
	.name = "Compro VideoMate H900",
	.comment = "Analog TV capture supported\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_all = CX18_HW_TUNER,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
@@ -201,8 +201,8 @@ static const struct cx18_card cx18_card_mpc718 = {
	.name = "Yuan MPC718",
	.comment = "Analog video capture works; some audio line in may not.\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_all = CX18_HW_TUNER,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
@@ -251,9 +251,9 @@ static const struct cx18_card cx18_card_cnxt_raptor_pal = {
	.name = "Conexant Raptor PAL/SECAM",
	.comment = "Analog TV capture supported\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_muxer = CX18_HW_GPIO,
	.hw_all = CX18_HW_TUNER | CX18_HW_GPIO,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_muxer = CX18_HW_GPIO_AUDIO_MUX,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_AUDIO_MUX,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
@@ -306,8 +306,8 @@ static const struct cx18_card cx18_card_toshiba_qosmio_dvbt = {
	.comment = "Experimenters and photos needed for device to work well.\n"
		  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_all = CX18_HW_TUNER,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE6 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
@@ -350,9 +350,9 @@ static const struct cx18_card cx18_card_leadtek_pvr2100 = {
	.comment = "Experimenters and photos needed for device to work well.\n"
		  "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
	.v4l2_capabilities = CX18_CAP_ENCODER,
	.hw_audio_ctrl = CX18_HW_CX23418,
	.hw_muxer = CX18_HW_GPIO,
	.hw_all = CX18_HW_TUNER | CX18_HW_GPIO,
	.hw_audio_ctrl = CX18_HW_418_AV,
	.hw_muxer = CX18_HW_GPIO_AUDIO_MUX,
	.hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_AUDIO_MUX,
	.video_inputs = {
		{ CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
		{ CX18_CARD_INPUT_SVIDEO1,    1,
Loading