aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx18/cx18-ioctl.c')
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index a7f839631d6a..f0ca50f5fdde 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include "cx18-driver.h" 24#include "cx18-driver.h"
25#include "cx18-io.h"
25#include "cx18-version.h" 26#include "cx18-version.h"
26#include "cx18-mailbox.h" 27#include "cx18-mailbox.h"
27#include "cx18-i2c.h" 28#include "cx18-i2c.h"
@@ -170,7 +171,6 @@ static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
170{ 171{
171 struct cx18_open_id *id = fh; 172 struct cx18_open_id *id = fh;
172 struct cx18 *cx = id->cx; 173 struct cx18 *cx = id->cx;
173
174 int w = fmt->fmt.pix.width; 174 int w = fmt->fmt.pix.width;
175 int h = fmt->fmt.pix.height; 175 int h = fmt->fmt.pix.height;
176 176
@@ -202,8 +202,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
202 struct cx18_open_id *id = fh; 202 struct cx18_open_id *id = fh;
203 struct cx18 *cx = id->cx; 203 struct cx18 *cx = id->cx;
204 int ret; 204 int ret;
205 int w = fmt->fmt.pix.width; 205 int w, h;
206 int h = fmt->fmt.pix.height;
207 206
208 ret = v4l2_prio_check(&cx->prio, &id->prio); 207 ret = v4l2_prio_check(&cx->prio, &id->prio);
209 if (ret) 208 if (ret)
@@ -212,6 +211,8 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
212 ret = cx18_try_fmt_vid_cap(file, fh, fmt); 211 ret = cx18_try_fmt_vid_cap(file, fh, fmt);
213 if (ret) 212 if (ret)
214 return ret; 213 return ret;
214 w = fmt->fmt.pix.width;
215 h = fmt->fmt.pix.height;
215 216
216 if (cx->params.width == w && cx->params.height == h) 217 if (cx->params.width == w && cx->params.height == h)
217 return 0; 218 return 0;
@@ -286,9 +287,9 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
286 287
287 spin_lock_irqsave(&cx18_cards_lock, flags); 288 spin_lock_irqsave(&cx18_cards_lock, flags);
288 if (cmd == VIDIOC_DBG_G_REGISTER) 289 if (cmd == VIDIOC_DBG_G_REGISTER)
289 regs->val = read_enc(regs->reg); 290 regs->val = cx18_read_enc(cx, regs->reg);
290 else 291 else
291 write_enc(regs->val, regs->reg); 292 cx18_write_enc(cx, regs->val, regs->reg);
292 spin_unlock_irqrestore(&cx18_cards_lock, flags); 293 spin_unlock_irqrestore(&cx18_cards_lock, flags);
293 return 0; 294 return 0;
294} 295}
@@ -345,7 +346,7 @@ static int cx18_querycap(struct file *file, void *fh,
345 346
346 strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); 347 strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
347 strlcpy(vcap->card, cx->card_name, sizeof(vcap->card)); 348 strlcpy(vcap->card, cx->card_name, sizeof(vcap->card));
348 strlcpy(vcap->bus_info, pci_name(cx->dev), sizeof(vcap->bus_info)); 349 snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(cx->dev));
349 vcap->version = CX18_DRIVER_VERSION; /* version */ 350 vcap->version = CX18_DRIVER_VERSION; /* version */
350 vcap->capabilities = cx->v4l2_cap; /* capabilities */ 351 vcap->capabilities = cx->v4l2_cap; /* capabilities */
351 return 0; 352 return 0;
@@ -622,6 +623,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
622{ 623{
623 struct cx18_open_id *id = fh; 624 struct cx18_open_id *id = fh;
624 struct cx18 *cx = id->cx; 625 struct cx18 *cx = id->cx;
626 u32 h;
625 627
626 switch (enc->cmd) { 628 switch (enc->cmd) {
627 case V4L2_ENC_CMD_START: 629 case V4L2_ENC_CMD_START:
@@ -643,8 +645,14 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
643 return -EPERM; 645 return -EPERM;
644 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) 646 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
645 return 0; 647 return 0;
648 h = cx18_find_handle(cx);
649 if (h == CX18_INVALID_TASK_HANDLE) {
650 CX18_ERR("Can't find valid task handle for "
651 "V4L2_ENC_CMD_PAUSE\n");
652 return -EBADFD;
653 }
646 cx18_mute(cx); 654 cx18_mute(cx);
647 cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, cx18_find_handle(cx)); 655 cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, h);
648 break; 656 break;
649 657
650 case V4L2_ENC_CMD_RESUME: 658 case V4L2_ENC_CMD_RESUME:
@@ -654,7 +662,13 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
654 return -EPERM; 662 return -EPERM;
655 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) 663 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
656 return 0; 664 return 0;
657 cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, cx18_find_handle(cx)); 665 h = cx18_find_handle(cx);
666 if (h == CX18_INVALID_TASK_HANDLE) {
667 CX18_ERR("Can't find valid task handle for "
668 "V4L2_ENC_CMD_RESUME\n");
669 return -EBADFD;
670 }
671 cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h);
658 cx18_unmute(cx); 672 cx18_unmute(cx);
659 break; 673 break;
660 674
@@ -731,12 +745,14 @@ static int cx18_log_status(struct file *file, void *fh)
731 continue; 745 continue;
732 CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n", 746 CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n",
733 s->name, s->s_flags, 747 s->name, s->s_flags,
734 (s->buffers - s->q_free.buffers) * 100 / s->buffers, 748 (s->buffers - atomic_read(&s->q_free.buffers))
749 * 100 / s->buffers,
735 (s->buffers * s->buf_size) / 1024, s->buffers); 750 (s->buffers * s->buf_size) / 1024, s->buffers);
736 } 751 }
737 CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n", 752 CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n",
738 (long long)cx->mpg_data_received, 753 (long long)cx->mpg_data_received,
739 (long long)cx->vbi_data_inserted); 754 (long long)cx->vbi_data_inserted);
755 cx18_log_statistics(cx);
740 CX18_INFO("================== END STATUS CARD #%d ==================\n", cx->num); 756 CX18_INFO("================== END STATUS CARD #%d ==================\n", cx->num);
741 return 0; 757 return 0;
742} 758}