diff options
-rw-r--r-- | drivers/staging/media/go7007/Makefile | 2 | ||||
-rw-r--r-- | drivers/staging/media/go7007/saa7134-go7007.c | 117 |
2 files changed, 72 insertions, 47 deletions
diff --git a/drivers/staging/media/go7007/Makefile b/drivers/staging/media/go7007/Makefile index 507d01276ac1..bbc8a32027ec 100644 --- a/drivers/staging/media/go7007/Makefile +++ b/drivers/staging/media/go7007/Makefile | |||
@@ -10,7 +10,7 @@ s2250-y := s2250-board.o | |||
10 | 10 | ||
11 | # Uncomment when the saa7134 patches get into upstream | 11 | # Uncomment when the saa7134 patches get into upstream |
12 | #obj-$(CONFIG_VIDEO_SAA7134) += saa7134-go7007.o | 12 | #obj-$(CONFIG_VIDEO_SAA7134) += saa7134-go7007.o |
13 | #ccflags-$(CONFIG_VIDEO_SAA7134:m=y) += -Idrivers/media/video/saa7134 -DSAA7134_MPEG_GO7007=3 | 13 | #ccflags-$(CONFIG_VIDEO_SAA7134:m=y) += -Idrivers/media/pci/saa7134 |
14 | 14 | ||
15 | # go7007-loader needs cypress ezusb loader from dvb-usb-v2 | 15 | # go7007-loader needs cypress ezusb loader from dvb-usb-v2 |
16 | ccflags-$(CONFIG_VIDEO_GO7007_LOADER:m=y) += -Idrivers/media/usb/dvb-usb-v2 | 16 | ccflags-$(CONFIG_VIDEO_GO7007_LOADER:m=y) += -Idrivers/media/usb/dvb-usb-v2 |
diff --git a/drivers/staging/media/go7007/saa7134-go7007.c b/drivers/staging/media/go7007/saa7134-go7007.c index aee9acee366a..7ccbfe7784cf 100644 --- a/drivers/staging/media/go7007/saa7134-go7007.c +++ b/drivers/staging/media/go7007/saa7134-go7007.c | |||
@@ -28,12 +28,15 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <asm/byteorder.h> | 29 | #include <asm/byteorder.h> |
30 | #include <media/v4l2-common.h> | 30 | #include <media/v4l2-common.h> |
31 | #include <media/v4l2-device.h> | ||
32 | #include <media/v4l2-subdev.h> | ||
31 | 33 | ||
32 | #include "saa7134-reg.h" | ||
33 | #include "saa7134.h" | 34 | #include "saa7134.h" |
35 | #include "saa7134-reg.h" | ||
36 | #include "go7007.h" | ||
34 | #include "go7007-priv.h" | 37 | #include "go7007-priv.h" |
35 | 38 | ||
36 | #define GO7007_HPI_DEBUG | 39 | /*#define GO7007_HPI_DEBUG*/ |
37 | 40 | ||
38 | enum hpi_address { | 41 | enum hpi_address { |
39 | HPI_ADDR_VIDEO_BUFFER = 0xe4, | 42 | HPI_ADDR_VIDEO_BUFFER = 0xe4, |
@@ -57,6 +60,7 @@ enum gpio_command { | |||
57 | }; | 60 | }; |
58 | 61 | ||
59 | struct saa7134_go7007 { | 62 | struct saa7134_go7007 { |
63 | struct v4l2_subdev sd; | ||
60 | struct saa7134_dev *dev; | 64 | struct saa7134_dev *dev; |
61 | u8 *top; | 65 | u8 *top; |
62 | u8 *bottom; | 66 | u8 *bottom; |
@@ -64,6 +68,11 @@ struct saa7134_go7007 { | |||
64 | dma_addr_t bottom_dma; | 68 | dma_addr_t bottom_dma; |
65 | }; | 69 | }; |
66 | 70 | ||
71 | static inline struct saa7134_go7007 *to_state(struct v4l2_subdev *sd) | ||
72 | { | ||
73 | return container_of(sd, struct saa7134_go7007, sd); | ||
74 | } | ||
75 | |||
67 | static const struct go7007_board_info board_voyager = { | 76 | static const struct go7007_board_info board_voyager = { |
68 | .flags = 0, | 77 | .flags = 0, |
69 | .sensor_flags = GO7007_SENSOR_656 | | 78 | .sensor_flags = GO7007_SENSOR_656 | |
@@ -83,7 +92,6 @@ static const struct go7007_board_info board_voyager = { | |||
83 | }, | 92 | }, |
84 | }, | 93 | }, |
85 | }; | 94 | }; |
86 | MODULE_FIRMWARE("go7007tv.bin"); | ||
87 | 95 | ||
88 | /********************* Driver for GPIO HPI interface *********************/ | 96 | /********************* Driver for GPIO HPI interface *********************/ |
89 | 97 | ||
@@ -379,47 +387,6 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, u8 *data, int len) | |||
379 | return 0; | 387 | return 0; |
380 | } | 388 | } |
381 | 389 | ||
382 | static int saa7134_go7007_send_command(struct go7007 *go, unsigned int cmd, | ||
383 | void *arg) | ||
384 | { | ||
385 | struct saa7134_go7007 *saa = go->hpi_context; | ||
386 | struct saa7134_dev *dev = saa->dev; | ||
387 | |||
388 | switch (cmd) { | ||
389 | case VIDIOC_S_STD: | ||
390 | { | ||
391 | v4l2_std_id *std = arg; | ||
392 | return saa7134_s_std_internal(dev, NULL, std); | ||
393 | } | ||
394 | case VIDIOC_G_STD: | ||
395 | { | ||
396 | v4l2_std_id *std = arg; | ||
397 | *std = dev->tvnorm->id; | ||
398 | return 0; | ||
399 | } | ||
400 | case VIDIOC_QUERYCTRL: | ||
401 | { | ||
402 | struct v4l2_queryctrl *ctrl = arg; | ||
403 | if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER) | ||
404 | return saa7134_queryctrl(NULL, NULL, ctrl); | ||
405 | } | ||
406 | case VIDIOC_G_CTRL: | ||
407 | { | ||
408 | struct v4l2_control *ctrl = arg; | ||
409 | if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER) | ||
410 | return saa7134_g_ctrl_internal(dev, NULL, ctrl); | ||
411 | } | ||
412 | case VIDIOC_S_CTRL: | ||
413 | { | ||
414 | struct v4l2_control *ctrl = arg; | ||
415 | if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER) | ||
416 | return saa7134_s_ctrl_internal(dev, NULL, ctrl); | ||
417 | } | ||
418 | } | ||
419 | return -EINVAL; | ||
420 | |||
421 | } | ||
422 | |||
423 | static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { | 390 | static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { |
424 | .interface_reset = saa7134_go7007_interface_reset, | 391 | .interface_reset = saa7134_go7007_interface_reset, |
425 | .write_interrupt = saa7134_go7007_write_interrupt, | 392 | .write_interrupt = saa7134_go7007_write_interrupt, |
@@ -427,16 +394,63 @@ static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { | |||
427 | .stream_start = saa7134_go7007_stream_start, | 394 | .stream_start = saa7134_go7007_stream_start, |
428 | .stream_stop = saa7134_go7007_stream_stop, | 395 | .stream_stop = saa7134_go7007_stream_stop, |
429 | .send_firmware = saa7134_go7007_send_firmware, | 396 | .send_firmware = saa7134_go7007_send_firmware, |
430 | .send_command = saa7134_go7007_send_command, | ||
431 | }; | 397 | }; |
432 | MODULE_FIRMWARE("go7007/go7007tv.bin"); | 398 | MODULE_FIRMWARE("go7007/go7007tv.bin"); |
433 | 399 | ||
400 | /* --------------------------------------------------------------------------*/ | ||
401 | |||
402 | static int saa7134_go7007_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) | ||
403 | { | ||
404 | struct saa7134_go7007 *saa = to_state(sd); | ||
405 | struct saa7134_dev *dev = saa->dev; | ||
406 | |||
407 | return saa7134_s_std_internal(dev, NULL, norm); | ||
408 | } | ||
409 | |||
410 | static int saa7134_go7007_queryctrl(struct v4l2_subdev *sd, | ||
411 | struct v4l2_queryctrl *query) | ||
412 | { | ||
413 | return saa7134_queryctrl(NULL, NULL, query); | ||
414 | } | ||
415 | static int saa7134_go7007_s_ctrl(struct v4l2_subdev *sd, | ||
416 | struct v4l2_control *ctrl) | ||
417 | { | ||
418 | struct saa7134_go7007 *saa = to_state(sd); | ||
419 | struct saa7134_dev *dev = saa->dev; | ||
420 | return saa7134_s_ctrl_internal(dev, NULL, ctrl); | ||
421 | } | ||
422 | |||
423 | static int saa7134_go7007_g_ctrl(struct v4l2_subdev *sd, | ||
424 | struct v4l2_control *ctrl) | ||
425 | { | ||
426 | struct saa7134_go7007 *saa = to_state(sd); | ||
427 | struct saa7134_dev *dev = saa->dev; | ||
428 | return saa7134_g_ctrl_internal(dev, NULL, ctrl); | ||
429 | } | ||
430 | |||
431 | /* --------------------------------------------------------------------------*/ | ||
432 | |||
433 | static const struct v4l2_subdev_core_ops saa7134_go7007_core_ops = { | ||
434 | .g_ctrl = saa7134_go7007_g_ctrl, | ||
435 | .s_ctrl = saa7134_go7007_s_ctrl, | ||
436 | .queryctrl = saa7134_go7007_queryctrl, | ||
437 | .s_std = saa7134_go7007_s_std, | ||
438 | }; | ||
439 | |||
440 | static const struct v4l2_subdev_ops saa7134_go7007_sd_ops = { | ||
441 | .core = &saa7134_go7007_core_ops, | ||
442 | }; | ||
443 | |||
444 | /* --------------------------------------------------------------------------*/ | ||
445 | |||
446 | |||
434 | /********************* Add/remove functions *********************/ | 447 | /********************* Add/remove functions *********************/ |
435 | 448 | ||
436 | static int saa7134_go7007_init(struct saa7134_dev *dev) | 449 | static int saa7134_go7007_init(struct saa7134_dev *dev) |
437 | { | 450 | { |
438 | struct go7007 *go; | 451 | struct go7007 *go; |
439 | struct saa7134_go7007 *saa; | 452 | struct saa7134_go7007 *saa; |
453 | struct v4l2_subdev *sd; | ||
440 | 454 | ||
441 | printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n"); | 455 | printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n"); |
442 | 456 | ||
@@ -444,6 +458,12 @@ static int saa7134_go7007_init(struct saa7134_dev *dev) | |||
444 | if (saa == NULL) | 458 | if (saa == NULL) |
445 | return -ENOMEM; | 459 | return -ENOMEM; |
446 | 460 | ||
461 | /* Init the subdevice interface */ | ||
462 | sd = &saa->sd; | ||
463 | v4l2_subdev_init(sd, &saa7134_go7007_sd_ops); | ||
464 | v4l2_set_subdevdata(sd, saa); | ||
465 | strncpy(sd->name, "saa7134-go7007", sizeof(sd->name)); | ||
466 | |||
447 | /* Allocate a couple pages for receiving the compressed stream */ | 467 | /* Allocate a couple pages for receiving the compressed stream */ |
448 | saa->top = (u8 *)get_zeroed_page(GFP_KERNEL); | 468 | saa->top = (u8 *)get_zeroed_page(GFP_KERNEL); |
449 | if (!saa->top) | 469 | if (!saa->top) |
@@ -471,8 +491,12 @@ static int saa7134_go7007_init(struct saa7134_dev *dev) | |||
471 | * V4L2 and ALSA interfaces */ | 491 | * V4L2 and ALSA interfaces */ |
472 | if (go7007_register_encoder(go, go->board_info->num_i2c_devs) < 0) | 492 | if (go7007_register_encoder(go, go->board_info->num_i2c_devs) < 0) |
473 | goto initfail; | 493 | goto initfail; |
494 | |||
495 | /* Register the subdevice interface with the go7007 device */ | ||
496 | if (v4l2_device_register_subdev(&go->v4l2_dev, sd) < 0) | ||
497 | printk(KERN_INFO "saa7134-go7007: register subdev failed\n"); | ||
498 | |||
474 | dev->empress_dev = &go->vdev; | 499 | dev->empress_dev = &go->vdev; |
475 | video_set_drvdata(dev->empress_dev, go); | ||
476 | 500 | ||
477 | go->status = STATUS_ONLINE; | 501 | go->status = STATUS_ONLINE; |
478 | return 0; | 502 | return 0; |
@@ -506,6 +530,7 @@ static int saa7134_go7007_fini(struct saa7134_dev *dev) | |||
506 | go->status = STATUS_SHUTDOWN; | 530 | go->status = STATUS_SHUTDOWN; |
507 | free_page((unsigned long)saa->top); | 531 | free_page((unsigned long)saa->top); |
508 | free_page((unsigned long)saa->bottom); | 532 | free_page((unsigned long)saa->bottom); |
533 | v4l2_device_unregister_subdev(&saa->sd); | ||
509 | kfree(saa); | 534 | kfree(saa); |
510 | video_unregister_device(&go->vdev); | 535 | video_unregister_device(&go->vdev); |
511 | 536 | ||