aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Klimov <klimov.linux@gmail.com>2009-02-05 06:53:02 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:40 -0400
commitdb821804f4c0b0c667c9c928b49f62678d3931dd (patch)
tree7de9b0c04167bce99e3c560edf484961e38a65f0
parent8edafcc63d2a4a9e108c1f52689b1ff22b91b233 (diff)
V4L/DVB (10458): radio-mr800: move radio start and stop in one function
Patch introduces new amradio_set_mute function. Amradio_start and amradio_stop removed. This makes driver more flexible and it's useful for next changes. Signed-off-by: Alexey Klimov <klimov.linux@gmail.com> Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/radio/radio-mr800.c64
1 files changed, 21 insertions, 43 deletions
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 12cdb1f850c6..ebc9d9979c71 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -87,6 +87,16 @@ devices, that would be 76 and 91. */
87#define FREQ_MAX 108.0 87#define FREQ_MAX 108.0
88#define FREQ_MUL 16000 88#define FREQ_MUL 16000
89 89
90/*
91 * Commands that device should understand
92 * List isnt full and will be updated with implementation of new functions
93 */
94#define AMRADIO_SET_MUTE 0xab
95
96/* Comfortable defines for amradio_set_mute */
97#define AMRADIO_START 0x00
98#define AMRADIO_STOP 0x01
99
90/* module parameter */ 100/* module parameter */
91static int radio_nr = -1; 101static int radio_nr = -1;
92module_param(radio_nr, int, 0); 102module_param(radio_nr, int, 0);
@@ -169,40 +179,8 @@ static struct usb_driver usb_amradio_driver = {
169 .supports_autosuspend = 0, 179 .supports_autosuspend = 0,
170}; 180};
171 181
172/* switch on radio. Send 8 bytes to device. */ 182/* switch on/off the radio. Send 8 bytes to device */
173static int amradio_start(struct amradio_device *radio) 183static int amradio_set_mute(struct amradio_device *radio, char argument)
174{
175 int retval;
176 int size;
177
178 mutex_lock(&radio->lock);
179
180 radio->buffer[0] = 0x00;
181 radio->buffer[1] = 0x55;
182 radio->buffer[2] = 0xaa;
183 radio->buffer[3] = 0x00;
184 radio->buffer[4] = 0xab;
185 radio->buffer[5] = 0x00;
186 radio->buffer[6] = 0x00;
187 radio->buffer[7] = 0x00;
188
189 retval = usb_bulk_msg(radio->usbdev, usb_sndintpipe(radio->usbdev, 2),
190 (void *) (radio->buffer), BUFFER_LENGTH, &size, USB_TIMEOUT);
191
192 if (retval) {
193 mutex_unlock(&radio->lock);
194 return retval;
195 }
196
197 radio->muted = 0;
198
199 mutex_unlock(&radio->lock);
200
201 return retval;
202}
203
204/* switch off radio */
205static int amradio_stop(struct amradio_device *radio)
206{ 184{
207 int retval; 185 int retval;
208 int size; 186 int size;
@@ -217,8 +195,8 @@ static int amradio_stop(struct amradio_device *radio)
217 radio->buffer[1] = 0x55; 195 radio->buffer[1] = 0x55;
218 radio->buffer[2] = 0xaa; 196 radio->buffer[2] = 0xaa;
219 radio->buffer[3] = 0x00; 197 radio->buffer[3] = 0x00;
220 radio->buffer[4] = 0xab; 198 radio->buffer[4] = AMRADIO_SET_MUTE;
221 radio->buffer[5] = 0x01; 199 radio->buffer[5] = argument;
222 radio->buffer[6] = 0x00; 200 radio->buffer[6] = 0x00;
223 radio->buffer[7] = 0x00; 201 radio->buffer[7] = 0x00;
224 202
@@ -230,7 +208,7 @@ static int amradio_stop(struct amradio_device *radio)
230 return retval; 208 return retval;
231 } 209 }
232 210
233 radio->muted = 1; 211 radio->muted = argument;
234 212
235 mutex_unlock(&radio->lock); 213 mutex_unlock(&radio->lock);
236 214
@@ -451,14 +429,14 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
451 switch (ctrl->id) { 429 switch (ctrl->id) {
452 case V4L2_CID_AUDIO_MUTE: 430 case V4L2_CID_AUDIO_MUTE:
453 if (ctrl->value) { 431 if (ctrl->value) {
454 retval = amradio_stop(radio); 432 retval = amradio_set_mute(radio, AMRADIO_STOP);
455 if (retval < 0) { 433 if (retval < 0) {
456 amradio_dev_warn(&radio->videodev->dev, 434 amradio_dev_warn(&radio->videodev->dev,
457 "amradio_stop failed\n"); 435 "amradio_stop failed\n");
458 return -1; 436 return -1;
459 } 437 }
460 } else { 438 } else {
461 retval = amradio_start(radio); 439 retval = amradio_set_mute(radio, AMRADIO_START);
462 if (retval < 0) { 440 if (retval < 0) {
463 amradio_dev_warn(&radio->videodev->dev, 441 amradio_dev_warn(&radio->videodev->dev,
464 "amradio_start failed\n"); 442 "amradio_start failed\n");
@@ -517,7 +495,7 @@ static int usb_amradio_open(struct file *file)
517 radio->users = 1; 495 radio->users = 1;
518 radio->muted = 1; 496 radio->muted = 1;
519 497
520 retval = amradio_start(radio); 498 retval = amradio_set_mute(radio, AMRADIO_START);
521 if (retval < 0) { 499 if (retval < 0) {
522 amradio_dev_warn(&radio->videodev->dev, 500 amradio_dev_warn(&radio->videodev->dev,
523 "radio did not start up properly\n"); 501 "radio did not start up properly\n");
@@ -547,7 +525,7 @@ static int usb_amradio_close(struct file *file)
547 radio->users = 0; 525 radio->users = 0;
548 526
549 if (!radio->removed) { 527 if (!radio->removed) {
550 retval = amradio_stop(radio); 528 retval = amradio_set_mute(radio, AMRADIO_STOP);
551 if (retval < 0) 529 if (retval < 0)
552 amradio_dev_warn(&radio->videodev->dev, 530 amradio_dev_warn(&radio->videodev->dev,
553 "amradio_stop failed\n"); 531 "amradio_stop failed\n");
@@ -562,7 +540,7 @@ static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message)
562 struct amradio_device *radio = usb_get_intfdata(intf); 540 struct amradio_device *radio = usb_get_intfdata(intf);
563 int retval; 541 int retval;
564 542
565 retval = amradio_stop(radio); 543 retval = amradio_set_mute(radio, AMRADIO_STOP);
566 if (retval < 0) 544 if (retval < 0)
567 dev_warn(&intf->dev, "amradio_stop failed\n"); 545 dev_warn(&intf->dev, "amradio_stop failed\n");
568 546
@@ -577,7 +555,7 @@ static int usb_amradio_resume(struct usb_interface *intf)
577 struct amradio_device *radio = usb_get_intfdata(intf); 555 struct amradio_device *radio = usb_get_intfdata(intf);
578 int retval; 556 int retval;
579 557
580 retval = amradio_start(radio); 558 retval = amradio_set_mute(radio, AMRADIO_START);
581 if (retval < 0) 559 if (retval < 0)
582 dev_warn(&intf->dev, "amradio_start failed\n"); 560 dev_warn(&intf->dev, "amradio_start failed\n");
583 561