saa7134.h (a00e68888d5d2b583b13d7d58204a27207af95fd) saa7134.h (2ada815fc48bb0267876c2c24b275bd06485f746)
1/*
2 *
3 * v4l2 device driver for philips saa7134 based TV cards
4 *
5 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 27 unchanged lines hidden (view full) ---

36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-device.h>
39#include <media/v4l2-fh.h>
40#include <media/v4l2-ctrls.h>
41#include <media/tuner.h>
42#include <media/rc-core.h>
43#include <media/ir-kbd-i2c.h>
1/*
2 *
3 * v4l2 device driver for philips saa7134 based TV cards
4 *
5 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 27 unchanged lines hidden (view full) ---

36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-device.h>
39#include <media/v4l2-fh.h>
40#include <media/v4l2-ctrls.h>
41#include <media/tuner.h>
42#include <media/rc-core.h>
43#include <media/ir-kbd-i2c.h>
44#include <media/videobuf-dma-sg.h>
44#include <media/videobuf2-dma-sg.h>
45#include <sound/core.h>
46#include <sound/pcm.h>
47#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
45#include <sound/core.h>
46#include <sound/pcm.h>
47#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
48#include <media/videobuf-dvb.h>
48#include <media/videobuf2-dvb.h>
49#endif
50#include "tda8290.h"
51
52#define UNSET (-1U)
53
54/* ----------------------------------------------------------- */
55/* enums */
56

--- 391 unchanged lines hidden (view full) ---

448 unsigned int scan2;
449 unsigned int mode;
450 unsigned int stopped;
451};
452
453/* buffer for one video/vbi/ts frame */
454struct saa7134_buf {
455 /* common v4l buffer stuff -- must be first */
49#endif
50#include "tda8290.h"
51
52#define UNSET (-1U)
53
54/* ----------------------------------------------------------- */
55/* enums */
56

--- 391 unchanged lines hidden (view full) ---

448 unsigned int scan2;
449 unsigned int mode;
450 unsigned int stopped;
451};
452
453/* buffer for one video/vbi/ts frame */
454struct saa7134_buf {
455 /* common v4l buffer stuff -- must be first */
456 struct videobuf_buffer vb;
456 struct vb2_buffer vb2;
457
458 /* saa7134 specific */
459 unsigned int top_seen;
460 int (*activate)(struct saa7134_dev *dev,
461 struct saa7134_buf *buf,
462 struct saa7134_buf *next);
457
458 /* saa7134 specific */
459 unsigned int top_seen;
460 int (*activate)(struct saa7134_dev *dev,
461 struct saa7134_buf *buf,
462 struct saa7134_buf *next);
463
464 struct list_head entry;
463};
464
465struct saa7134_dmaqueue {
466 struct saa7134_dev *dev;
467 struct saa7134_buf *curr;
468 struct list_head queue;
469 struct timer_list timeout;
470 unsigned int need_two;
465};
466
467struct saa7134_dmaqueue {
468 struct saa7134_dev *dev;
469 struct saa7134_buf *curr;
470 struct list_head queue;
471 struct timer_list timeout;
472 unsigned int need_two;
473 unsigned int seq_nr;
471 struct saa7134_pgtable pt;
472};
473
474 struct saa7134_pgtable pt;
475};
476
474/* video filehandle status */
475struct saa7134_fh {
476 struct v4l2_fh fh;
477 bool is_empress;
478 unsigned int resources;
479};
480
481/* dmasound dsp status */
482struct saa7134_dmasound {
483 struct mutex lock;
484 int minor_mixer;
485 int minor_dsp;
486 unsigned int users_dsp;
487
488 /* mixer */

--- 89 unchanged lines hidden (view full) ---

578 /* video overlay */
579 struct v4l2_framebuffer ovbuf;
580 struct saa7134_format *ovfmt;
581 unsigned int ovenable;
582 enum v4l2_field ovfield;
583 struct v4l2_window win;
584 struct v4l2_clip clips[8];
585 unsigned int nclips;
477/* dmasound dsp status */
478struct saa7134_dmasound {
479 struct mutex lock;
480 int minor_mixer;
481 int minor_dsp;
482 unsigned int users_dsp;
483
484 /* mixer */

--- 89 unchanged lines hidden (view full) ---

574 /* video overlay */
575 struct v4l2_framebuffer ovbuf;
576 struct saa7134_format *ovfmt;
577 unsigned int ovenable;
578 enum v4l2_field ovfield;
579 struct v4l2_window win;
580 struct v4l2_clip clips[8];
581 unsigned int nclips;
582 struct v4l2_fh *overlay_owner;
586
587
588 /* video+ts+vbi capture */
589 struct saa7134_dmaqueue video_q;
583
584
585 /* video+ts+vbi capture */
586 struct saa7134_dmaqueue video_q;
590 struct videobuf_queue video_vbq;
587 struct vb2_queue video_vbq;
591 struct saa7134_dmaqueue vbi_q;
588 struct saa7134_dmaqueue vbi_q;
592 struct videobuf_queue vbi_vbq;
593 unsigned int video_fieldcount;
594 unsigned int vbi_fieldcount;
589 struct vb2_queue vbi_vbq;
590 enum v4l2_field field;
595 struct saa7134_format *fmt;
596 unsigned int width, height;
597 unsigned int vbi_hlen, vbi_vlen;
598 struct pm_qos_request qos_request;
599
591 struct saa7134_format *fmt;
592 unsigned int width, height;
593 unsigned int vbi_hlen, vbi_vlen;
594 struct pm_qos_request qos_request;
595
596 /* SAA7134_MPEG_* */
597 struct saa7134_ts ts;
598 struct saa7134_dmaqueue ts_q;
599 enum v4l2_field ts_field;
600 int ts_started;
601 struct saa7134_mpeg_ops *mops;
602
603 /* SAA7134_MPEG_EMPRESS only */
604 struct video_device *empress_dev;
605 struct v4l2_subdev *empress_sd;
606 struct vb2_queue empress_vbq;
607 struct work_struct empress_workqueue;
608 int empress_started;
609 struct v4l2_ctrl_handler empress_ctrl_handler;
610
600 /* various v4l controls */
601 struct saa7134_tvnorm *tvnorm; /* video */
602 struct saa7134_tvaudio *tvaudio;
603 struct v4l2_ctrl_handler ctrl_handler;
604 unsigned int ctl_input;
605 int ctl_bright;
606 int ctl_contrast;
607 int ctl_hue;

--- 20 unchanged lines hidden (view full) ---

628 int last_carrier;
629 int nosignal;
630 unsigned int insuspend;
631 struct v4l2_ctrl_handler radio_ctrl_handler;
632
633 /* I2C keyboard data */
634 struct IR_i2c_init_data init_data;
635
611 /* various v4l controls */
612 struct saa7134_tvnorm *tvnorm; /* video */
613 struct saa7134_tvaudio *tvaudio;
614 struct v4l2_ctrl_handler ctrl_handler;
615 unsigned int ctl_input;
616 int ctl_bright;
617 int ctl_contrast;
618 int ctl_hue;

--- 20 unchanged lines hidden (view full) ---

639 int last_carrier;
640 int nosignal;
641 unsigned int insuspend;
642 struct v4l2_ctrl_handler radio_ctrl_handler;
643
644 /* I2C keyboard data */
645 struct IR_i2c_init_data init_data;
646
636 /* SAA7134_MPEG_* */
637 struct saa7134_ts ts;
638 struct saa7134_dmaqueue ts_q;
639 int ts_started;
640 struct saa7134_mpeg_ops *mops;
641
642 /* SAA7134_MPEG_EMPRESS only */
643 struct video_device *empress_dev;
644 struct v4l2_subdev *empress_sd;
645 struct videobuf_queue empress_vbq;
646 struct work_struct empress_workqueue;
647 int empress_started;
648 struct v4l2_ctrl_handler empress_ctrl_handler;
649
650#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
651 /* SAA7134_MPEG_DVB only */
647#if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
648 /* SAA7134_MPEG_DVB only */
652 struct videobuf_dvb_frontends frontends;
649 struct vb2_dvb_frontends frontends;
653 int (*original_demod_sleep)(struct dvb_frontend *fe);
654 int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
655 int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg);
656#endif
657 void (*gate_ctrl)(struct saa7134_dev *dev, int open);
658};
659
660/* ----------------------------------------------------------- */

--- 37 unchanged lines hidden (view full) ---

698 dev->gate_ctrl(dev, 1); \
699 _rc = v4l2_device_call_until_err(&(dev)->v4l2_dev, \
700 GRP_EMPRESS, o, f , ##args); \
701 if (dev->gate_ctrl) \
702 dev->gate_ctrl(dev, 0); \
703 _rc; \
704})
705
650 int (*original_demod_sleep)(struct dvb_frontend *fe);
651 int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
652 int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg);
653#endif
654 void (*gate_ctrl)(struct saa7134_dev *dev, int open);
655};
656
657/* ----------------------------------------------------------- */

--- 37 unchanged lines hidden (view full) ---

695 dev->gate_ctrl(dev, 1); \
696 _rc = v4l2_device_call_until_err(&(dev)->v4l2_dev, \
697 GRP_EMPRESS, o, f , ##args); \
698 if (dev->gate_ctrl) \
699 dev->gate_ctrl(dev, 0); \
700 _rc; \
701})
702
706static inline int res_check(struct saa7134_fh *fh, unsigned int bit)
703static inline bool is_empress(struct file *file)
707{
704{
708 return fh->resources & bit;
709}
705 struct video_device *vdev = video_devdata(file);
706 struct saa7134_dev *dev = video_get_drvdata(vdev);
710
707
711static inline int res_locked(struct saa7134_dev *dev, unsigned int bit)
712{
713 return dev->resources & bit;
708 return vdev->queue == &dev->empress_vbq;
714}
715
716/* ----------------------------------------------------------- */
717/* saa7134-core.c */
718
719extern struct list_head saa7134_devlist;
720extern struct mutex saa7134_devlist_lock;
721extern int saa7134_no_overlay;

--- 14 unchanged lines hidden (view full) ---

736unsigned long saa7134_buffer_base(struct saa7134_buf *buf);
737
738int saa7134_buffer_queue(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
739 struct saa7134_buf *buf);
740void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
741 unsigned int state);
742void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
743void saa7134_buffer_timeout(unsigned long data);
709}
710
711/* ----------------------------------------------------------- */
712/* saa7134-core.c */
713
714extern struct list_head saa7134_devlist;
715extern struct mutex saa7134_devlist_lock;
716extern int saa7134_no_overlay;

--- 14 unchanged lines hidden (view full) ---

731unsigned long saa7134_buffer_base(struct saa7134_buf *buf);
732
733int saa7134_buffer_queue(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
734 struct saa7134_buf *buf);
735void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
736 unsigned int state);
737void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
738void saa7134_buffer_timeout(unsigned long data);
744void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf);
739void saa7134_stop_streaming(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
745
746int saa7134_set_dmabits(struct saa7134_dev *dev);
747
748extern int (*saa7134_dmasound_init)(struct saa7134_dev *dev);
749extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
750
751
752/* ----------------------------------------------------------- */

--- 17 unchanged lines hidden (view full) ---

770
771/* ----------------------------------------------------------- */
772/* saa7134-video.c */
773
774extern unsigned int video_debug;
775extern struct video_device saa7134_video_template;
776extern struct video_device saa7134_radio_template;
777
740
741int saa7134_set_dmabits(struct saa7134_dev *dev);
742
743extern int (*saa7134_dmasound_init)(struct saa7134_dev *dev);
744extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
745
746
747/* ----------------------------------------------------------- */

--- 17 unchanged lines hidden (view full) ---

765
766/* ----------------------------------------------------------- */
767/* saa7134-video.c */
768
769extern unsigned int video_debug;
770extern struct video_device saa7134_video_template;
771extern struct video_device saa7134_radio_template;
772
773void saa7134_vb2_buffer_queue(struct vb2_buffer *vb);
774int saa7134_vb2_start_streaming(struct vb2_queue *vq, unsigned int count);
775void saa7134_vb2_stop_streaming(struct vb2_queue *vq);
776
778int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id);
779int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id);
780int saa7134_querystd(struct file *file, void *priv, v4l2_std_id *std);
781int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i);
782int saa7134_g_input(struct file *file, void *priv, unsigned int *i);
783int saa7134_s_input(struct file *file, void *priv, unsigned int i);
784int saa7134_querycap(struct file *file, void *priv,
785 struct v4l2_capability *cap);
786int saa7134_g_tuner(struct file *file, void *priv,
787 struct v4l2_tuner *t);
788int saa7134_s_tuner(struct file *file, void *priv,
789 const struct v4l2_tuner *t);
790int saa7134_g_frequency(struct file *file, void *priv,
791 struct v4l2_frequency *f);
792int saa7134_s_frequency(struct file *file, void *priv,
793 const struct v4l2_frequency *f);
777int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id);
778int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id);
779int saa7134_querystd(struct file *file, void *priv, v4l2_std_id *std);
780int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i);
781int saa7134_g_input(struct file *file, void *priv, unsigned int *i);
782int saa7134_s_input(struct file *file, void *priv, unsigned int i);
783int saa7134_querycap(struct file *file, void *priv,
784 struct v4l2_capability *cap);
785int saa7134_g_tuner(struct file *file, void *priv,
786 struct v4l2_tuner *t);
787int saa7134_s_tuner(struct file *file, void *priv,
788 const struct v4l2_tuner *t);
789int saa7134_g_frequency(struct file *file, void *priv,
790 struct v4l2_frequency *f);
791int saa7134_s_frequency(struct file *file, void *priv,
792 const struct v4l2_frequency *f);
794int saa7134_reqbufs(struct file *file, void *priv,
795 struct v4l2_requestbuffers *p);
796int saa7134_querybuf(struct file *file, void *priv,
797 struct v4l2_buffer *b);
798int saa7134_qbuf(struct file *file, void *priv, struct v4l2_buffer *b);
799int saa7134_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b);
800int saa7134_streamon(struct file *file, void *priv,
801 enum v4l2_buf_type type);
802int saa7134_streamoff(struct file *file, void *priv,
803 enum v4l2_buf_type type);
804
805int saa7134_videoport_init(struct saa7134_dev *dev);
806void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);
807
808int saa7134_video_init1(struct saa7134_dev *dev);
809int saa7134_video_init2(struct saa7134_dev *dev);
810void saa7134_irq_video_signalchange(struct saa7134_dev *dev);
811void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
812void saa7134_video_fini(struct saa7134_dev *dev);
813
814
815/* ----------------------------------------------------------- */
816/* saa7134-ts.c */
817
818#define TS_PACKET_SIZE 188 /* TS packets 188 bytes */
819
793
794int saa7134_videoport_init(struct saa7134_dev *dev);
795void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);
796
797int saa7134_video_init1(struct saa7134_dev *dev);
798int saa7134_video_init2(struct saa7134_dev *dev);
799void saa7134_irq_video_signalchange(struct saa7134_dev *dev);
800void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
801void saa7134_video_fini(struct saa7134_dev *dev);
802
803
804/* ----------------------------------------------------------- */
805/* saa7134-ts.c */
806
807#define TS_PACKET_SIZE 188 /* TS packets 188 bytes */
808
820extern struct videobuf_queue_ops saa7134_ts_qops;
809int saa7134_ts_buffer_init(struct vb2_buffer *vb2);
810int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2);
811void saa7134_ts_buffer_finish(struct vb2_buffer *vb2);
812int saa7134_ts_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
813 unsigned int *nbuffers, unsigned int *nplanes,
814 unsigned int sizes[], void *alloc_ctxs[]);
815int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count);
816void saa7134_ts_stop_streaming(struct vb2_queue *vq);
821
817
818extern struct vb2_ops saa7134_ts_qops;
819
822int saa7134_ts_init1(struct saa7134_dev *dev);
823int saa7134_ts_fini(struct saa7134_dev *dev);
824void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status);
825
826int saa7134_ts_register(struct saa7134_mpeg_ops *ops);
827void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops);
828
829int saa7134_ts_init_hw(struct saa7134_dev *dev);
830
831int saa7134_ts_start(struct saa7134_dev *dev);
832int saa7134_ts_stop(struct saa7134_dev *dev);
833
834/* ----------------------------------------------------------- */
835/* saa7134-vbi.c */
836
820int saa7134_ts_init1(struct saa7134_dev *dev);
821int saa7134_ts_fini(struct saa7134_dev *dev);
822void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status);
823
824int saa7134_ts_register(struct saa7134_mpeg_ops *ops);
825void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops);
826
827int saa7134_ts_init_hw(struct saa7134_dev *dev);
828
829int saa7134_ts_start(struct saa7134_dev *dev);
830int saa7134_ts_stop(struct saa7134_dev *dev);
831
832/* ----------------------------------------------------------- */
833/* saa7134-vbi.c */
834
837extern struct videobuf_queue_ops saa7134_vbi_qops;
835extern struct vb2_ops saa7134_vbi_qops;
838extern struct video_device saa7134_vbi_template;
839
840int saa7134_vbi_init1(struct saa7134_dev *dev);
841int saa7134_vbi_fini(struct saa7134_dev *dev);
842void saa7134_irq_vbi_done(struct saa7134_dev *dev, unsigned long status);
843
844
845/* ----------------------------------------------------------- */

--- 48 unchanged lines hidden ---
836extern struct video_device saa7134_vbi_template;
837
838int saa7134_vbi_init1(struct saa7134_dev *dev);
839int saa7134_vbi_fini(struct saa7134_dev *dev);
840void saa7134_irq_vbi_done(struct saa7134_dev *dev, unsigned long status);
841
842
843/* ----------------------------------------------------------- */

--- 48 unchanged lines hidden ---