static int ts_open(struct file *file) { struct video_device *vdev = video_devdata(file); struct saa7134_dev *dev = video_drvdata(file); int err; dprintk("open dev=%s\n", video_device_node_name(vdev)); err = -EBUSY; if (!mutex_trylock(&dev->empress_tsq.vb_lock)) return err; if (atomic_read(&dev->empress_users)) goto done; /* Unmute audio */ saa_writeb(SAA7134_AUDIO_MUTE_CTRL, saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6)); atomic_inc(&dev->empress_users); file->private_data = dev; err = 0; done: mutex_unlock(&dev->empress_tsq.vb_lock); return err; }
static int start_streaming(struct vb2_queue *vq, unsigned int count) { struct saa7134_dmaqueue *dmaq = vq->drv_priv; struct saa7134_dev *dev = dmaq->dev; u32 leading_null_bytes = 0; int err; err = saa7134_ts_start_streaming(vq, count); if (err) return err; /* If more cards start to need this, then this should probably be added to the card definitions. */ switch (dev->board) { case SAA7134_BOARD_BEHOLD_M6: case SAA7134_BOARD_BEHOLD_M63: case SAA7134_BOARD_BEHOLD_M6_EXTRA: leading_null_bytes = 1; break; } saa_call_all(dev, core, init, leading_null_bytes); /* Unmute audio */ saa_writeb(SAA7134_AUDIO_MUTE_CTRL, saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6)); dev->empress_started = 1; return 0; }
static int ts_open(struct file *file) { int minor = video_devdata(file)->minor; struct saa7134_dev *dev; int err; lock_kernel(); list_for_each_entry(dev, &saa7134_devlist, devlist) if (dev->empress_dev && dev->empress_dev->minor == minor) goto found; unlock_kernel(); return -ENODEV; found: dprintk("open minor=%d\n",minor); err = -EBUSY; if (!mutex_trylock(&dev->empress_tsq.vb_lock)) goto done; if (atomic_read(&dev->empress_users)) goto done_up; /* Unmute audio */ saa_writeb(SAA7134_AUDIO_MUTE_CTRL, saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6)); atomic_inc(&dev->empress_users); file->private_data = dev; err = 0; done_up: mutex_unlock(&dev->empress_tsq.vb_lock); done: unlock_kernel(); return err; }
static int ts_open(struct inode *inode, struct file *file) { int minor = iminor(inode); struct saa7134_dev *dev; int err; list_for_each_entry(dev, &saa7134_devlist, devlist) if (dev->empress_dev && dev->empress_dev->minor == minor) goto found; return -ENODEV; found: dprintk("open minor=%d\n",minor); err = -EBUSY; if (!mutex_trylock(&dev->empress_tsq.vb_lock)) goto done; if (dev->empress_users) goto done_up; /* Unmute audio */ saa_writeb(SAA7134_AUDIO_MUTE_CTRL, saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6)); dev->empress_users++; file->private_data = dev; err = 0; done_up: mutex_unlock(&dev->empress_tsq.vb_lock); done: return err; }
static inline enum i2c_status i2c_get_status(struct saa7134_dev *dev) { enum i2c_status status; status = saa_readb(SAA7134_I2C_ATTR_STATUS) & 0x0f; i2c_dbg(2, "i2c stat <= %s\n", str_i2c_status[status]); return status; }
static inline enum i2c_status i2c_get_status(struct saa7134_dev *dev) { enum i2c_status status; status = saa_readb(SAA7134_I2C_ATTR_STATUS) & 0x0f; d2printk(KERN_DEBUG "%s: i2c stat <= %s\n",dev->name, str_i2c_status[status]); return status; }
static void dump_statusreg(struct saa7134_dev *dev, int reg, char *regname, char **bits) { int value,i; value = saa_readb(reg); printk(KERN_DEBUG "%s: %s:", dev->name, regname); for (i = 7; i >= 0; i--) { if (NULL == bits[i]) continue; printk(" %s=%d", bits[i], (value & (1 << i)) ? 1 : 0); } printk("\n"); }
static inline int i2c_recv_byte(struct saa7134_dev *dev) { enum i2c_status status; unsigned char data; i2c_set_attr(dev,CONTINUE); if (!i2c_is_busy_wait(dev)) return -EIO; status = i2c_get_status(dev); if (i2c_is_error(status)) return -EIO; data = saa_readb(SAA7134_I2C_DATA); d2printk(KERN_DEBUG "%s: i2c data <= 0x%x\n",dev->name,data); return data; }
static void stop_streaming(struct vb2_queue *vq) { struct saa7134_dmaqueue *dmaq = vq->drv_priv; struct saa7134_dev *dev = dmaq->dev; saa7134_ts_stop_streaming(vq); saa_writeb(SAA7134_SPECIAL_MODE, 0x00); msleep(20); saa_writeb(SAA7134_SPECIAL_MODE, 0x01); msleep(100); /* Mute audio */ saa_writeb(SAA7134_AUDIO_MUTE_CTRL, saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); dev->empress_started = 0; }
static int ts_release(struct inode *inode, struct file *file) { struct saa7134_dev *dev = file->private_data; videobuf_stop(&dev->empress_tsq); videobuf_mmap_free(&dev->empress_tsq); dev->empress_users--; /* stop the encoder */ ts_reset_encoder(dev); /* Mute audio */ saa_writeb(SAA7134_AUDIO_MUTE_CTRL, saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); return 0; }