2010-06-18 01:27:26 +08:00
|
|
|
/*
|
2013-03-25 16:35:17 +08:00
|
|
|
* Copyright (C) 2010-2013 Bluecherry, LLC <http://www.bluecherrydvr.com>
|
|
|
|
*
|
|
|
|
* Original author:
|
|
|
|
* Ben Collins <bcollins@ubuntu.com>
|
|
|
|
*
|
|
|
|
* Additional work by:
|
|
|
|
* John Brooks <john.brooks@bluecherry.net>
|
2010-06-18 01:27:26 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kthread.h>
|
|
|
|
#include <linux/freezer.h>
|
2013-03-25 16:35:17 +08:00
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
#include <media/v4l2-ioctl.h>
|
|
|
|
#include <media/v4l2-common.h>
|
2013-03-13 05:47:03 +08:00
|
|
|
#include <media/v4l2-event.h>
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
#include <media/videobuf2-v4l2.h>
|
2013-03-15 23:11:17 +08:00
|
|
|
#include <media/videobuf2-dma-contig.h>
|
2013-03-25 16:35:17 +08:00
|
|
|
|
2011-02-11 20:36:27 +08:00
|
|
|
#include "solo6x10.h"
|
2013-03-25 16:42:46 +08:00
|
|
|
#include "solo6x10-tw28.h"
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
/* Image size is two fields, SOLO_HW_BPL is one horizontal line in hardware */
|
|
|
|
#define SOLO_HW_BPL 2048
|
2010-06-18 01:27:26 +08:00
|
|
|
#define solo_vlines(__solo) (__solo->video_vsize * 2)
|
|
|
|
#define solo_image_size(__solo) (solo_bytesperline(__solo) * \
|
|
|
|
solo_vlines(__solo))
|
|
|
|
#define solo_bytesperline(__solo) (__solo->video_hsize * 2)
|
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
#define MIN_VID_BUFFERS 2
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
static inline void erase_on(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
solo_reg_write(solo_dev, SOLO_VO_DISP_ERASE, SOLO_VO_DISP_ERASE_ON);
|
|
|
|
solo_dev->erasing = 1;
|
|
|
|
solo_dev->frame_blank = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
static inline int erase_off(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
if (!solo_dev->erasing)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* First time around, assert erase off */
|
|
|
|
if (!solo_dev->frame_blank)
|
|
|
|
solo_reg_write(solo_dev, SOLO_VO_DISP_ERASE, 0);
|
|
|
|
/* Keep the erasing flag on for 8 frames minimum */
|
|
|
|
if (solo_dev->frame_blank++ >= 8)
|
|
|
|
solo_dev->erasing = 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
void solo_video_in_isr(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-25 16:35:17 +08:00
|
|
|
wake_up_interruptible_all(&solo_dev->disp_thread_wait);
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
static void solo_win_setup(struct solo_dev *solo_dev, u8 ch,
|
2010-06-18 01:27:26 +08:00
|
|
|
int sx, int sy, int ex, int ey, int scale)
|
|
|
|
{
|
|
|
|
if (ch >= solo_dev->nr_chans)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Here, we just keep window/channel the same */
|
|
|
|
solo_reg_write(solo_dev, SOLO_VI_WIN_CTRL0(ch),
|
|
|
|
SOLO_VI_WIN_CHANNEL(ch) |
|
|
|
|
SOLO_VI_WIN_SX(sx) |
|
|
|
|
SOLO_VI_WIN_EX(ex) |
|
|
|
|
SOLO_VI_WIN_SCALE(scale));
|
|
|
|
|
2010-11-05 10:51:17 +08:00
|
|
|
solo_reg_write(solo_dev, SOLO_VI_WIN_CTRL1(ch),
|
2010-06-18 01:27:26 +08:00
|
|
|
SOLO_VI_WIN_SY(sy) |
|
|
|
|
SOLO_VI_WIN_EY(ey));
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
static int solo_v4l2_ch_ext_4up(struct solo_dev *solo_dev, u8 idx, int on)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
u8 ch = idx * 4;
|
|
|
|
|
|
|
|
if (ch >= solo_dev->nr_chans)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!on) {
|
|
|
|
u8 i;
|
2014-07-18 07:40:22 +08:00
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
for (i = ch; i < ch + 4; i++)
|
|
|
|
solo_win_setup(solo_dev, i, solo_dev->video_hsize,
|
|
|
|
solo_vlines(solo_dev),
|
|
|
|
solo_dev->video_hsize,
|
|
|
|
solo_vlines(solo_dev), 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Row 1 */
|
|
|
|
solo_win_setup(solo_dev, ch, 0, 0, solo_dev->video_hsize / 2,
|
|
|
|
solo_vlines(solo_dev) / 2, 3);
|
|
|
|
solo_win_setup(solo_dev, ch + 1, solo_dev->video_hsize / 2, 0,
|
|
|
|
solo_dev->video_hsize, solo_vlines(solo_dev) / 2, 3);
|
|
|
|
/* Row 2 */
|
|
|
|
solo_win_setup(solo_dev, ch + 2, 0, solo_vlines(solo_dev) / 2,
|
|
|
|
solo_dev->video_hsize / 2, solo_vlines(solo_dev), 3);
|
|
|
|
solo_win_setup(solo_dev, ch + 3, solo_dev->video_hsize / 2,
|
|
|
|
solo_vlines(solo_dev) / 2, solo_dev->video_hsize,
|
|
|
|
solo_vlines(solo_dev), 3);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
static int solo_v4l2_ch_ext_16up(struct solo_dev *solo_dev, int on)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
int sy, ysize, hsize, i;
|
|
|
|
|
|
|
|
if (!on) {
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
solo_win_setup(solo_dev, i, solo_dev->video_hsize,
|
|
|
|
solo_vlines(solo_dev),
|
|
|
|
solo_dev->video_hsize,
|
|
|
|
solo_vlines(solo_dev), 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ysize = solo_vlines(solo_dev) / 4;
|
|
|
|
hsize = solo_dev->video_hsize / 4;
|
|
|
|
|
|
|
|
for (sy = 0, i = 0; i < 4; i++, sy += ysize) {
|
|
|
|
solo_win_setup(solo_dev, i * 4, 0, sy, hsize,
|
|
|
|
sy + ysize, 5);
|
|
|
|
solo_win_setup(solo_dev, (i * 4) + 1, hsize, sy,
|
|
|
|
hsize * 2, sy + ysize, 5);
|
|
|
|
solo_win_setup(solo_dev, (i * 4) + 2, hsize * 2, sy,
|
|
|
|
hsize * 3, sy + ysize, 5);
|
|
|
|
solo_win_setup(solo_dev, (i * 4) + 3, hsize * 3, sy,
|
|
|
|
solo_dev->video_hsize, sy + ysize, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
static int solo_v4l2_ch(struct solo_dev *solo_dev, u8 ch, int on)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
u8 ext_ch;
|
|
|
|
|
|
|
|
if (ch < solo_dev->nr_chans) {
|
|
|
|
solo_win_setup(solo_dev, ch, on ? 0 : solo_dev->video_hsize,
|
|
|
|
on ? 0 : solo_vlines(solo_dev),
|
|
|
|
solo_dev->video_hsize, solo_vlines(solo_dev),
|
|
|
|
on ? 1 : 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch >= solo_dev->nr_chans + solo_dev->nr_ext)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ext_ch = ch - solo_dev->nr_chans;
|
|
|
|
|
|
|
|
/* 4up's first */
|
|
|
|
if (ext_ch < 4)
|
|
|
|
return solo_v4l2_ch_ext_4up(solo_dev, ext_ch, on);
|
|
|
|
|
|
|
|
/* Remaining case is 16up for 16-port */
|
|
|
|
return solo_v4l2_ch_ext_16up(solo_dev, on);
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
static int solo_v4l2_set_ch(struct solo_dev *solo_dev, u8 ch)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
if (ch >= solo_dev->nr_chans + solo_dev->nr_ext)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
erase_on(solo_dev);
|
|
|
|
|
|
|
|
solo_v4l2_ch(solo_dev, solo_dev->cur_disp_ch, 0);
|
|
|
|
solo_v4l2_ch(solo_dev, ch, 1);
|
|
|
|
|
|
|
|
solo_dev->cur_disp_ch = ch;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
static void solo_fillbuf(struct solo_dev *solo_dev,
|
2013-03-15 23:11:17 +08:00
|
|
|
struct vb2_buffer *vb)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
|
|
|
dma_addr_t addr;
|
2010-06-18 01:27:26 +08:00
|
|
|
unsigned int fdma_addr;
|
2013-03-25 16:35:17 +08:00
|
|
|
int error = -1;
|
2010-06-18 01:27:26 +08:00
|
|
|
int i;
|
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
addr = vb2_dma_contig_plane_dma_addr(vb, 0);
|
|
|
|
if (!addr)
|
2010-06-18 01:27:26 +08:00
|
|
|
goto finish_buf;
|
|
|
|
|
|
|
|
if (erase_off(solo_dev)) {
|
2013-03-15 23:11:17 +08:00
|
|
|
void *p = vb2_plane_vaddr(vb, 0);
|
2013-03-25 16:35:17 +08:00
|
|
|
int image_size = solo_image_size(solo_dev);
|
2014-07-18 07:40:22 +08:00
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
for (i = 0; i < image_size; i += 2) {
|
|
|
|
((u8 *)p)[i] = 0x80;
|
|
|
|
((u8 *)p)[i + 1] = 0x00;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
error = 0;
|
2013-03-25 16:35:17 +08:00
|
|
|
} else {
|
2013-03-15 22:56:46 +08:00
|
|
|
fdma_addr = SOLO_DISP_EXT_ADDR + (solo_dev->old_write *
|
2013-03-25 16:35:17 +08:00
|
|
|
(SOLO_HW_BPL * solo_vlines(solo_dev)));
|
2010-11-05 10:51:17 +08:00
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
error = solo_p2m_dma_t(solo_dev, 0, addr, fdma_addr,
|
2013-03-25 16:35:17 +08:00
|
|
|
solo_bytesperline(solo_dev),
|
|
|
|
solo_vlines(solo_dev), SOLO_HW_BPL);
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
2010-11-05 10:51:17 +08:00
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
finish_buf:
|
2013-03-15 23:11:17 +08:00
|
|
|
if (!error) {
|
|
|
|
vb2_set_plane_payload(vb, 0,
|
|
|
|
solo_vlines(solo_dev) * solo_bytesperline(solo_dev));
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
vbuf->sequence = solo_dev->sequence++;
|
2015-11-03 18:16:37 +08:00
|
|
|
vb->timestamp = ktime_get_ns();
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
vb2_buffer_done(vb, error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
static void solo_thread_try(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-15 23:11:17 +08:00
|
|
|
struct solo_vb2_buf *vb;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
/* Only "break" from this loop if slock is held, otherwise
|
|
|
|
* just return. */
|
2010-06-18 01:27:26 +08:00
|
|
|
for (;;) {
|
2013-03-25 16:35:17 +08:00
|
|
|
unsigned int cur_write;
|
|
|
|
|
|
|
|
cur_write = SOLO_VI_STATUS0_PAGE(
|
2013-03-15 22:56:46 +08:00
|
|
|
solo_reg_read(solo_dev, SOLO_VI_STATUS0));
|
|
|
|
if (cur_write == solo_dev->old_write)
|
2013-03-25 16:35:17 +08:00
|
|
|
return;
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
spin_lock(&solo_dev->slock);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
if (list_empty(&solo_dev->vidq_active))
|
2010-06-18 01:27:26 +08:00
|
|
|
break;
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
vb = list_first_entry(&solo_dev->vidq_active, struct solo_vb2_buf,
|
|
|
|
list);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
solo_dev->old_write = cur_write;
|
2013-03-15 23:11:17 +08:00
|
|
|
list_del(&vb->list);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
spin_unlock(&solo_dev->slock);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
solo_fillbuf(solo_dev, &vb->vb.vb2_buf);
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
assert_spin_locked(&solo_dev->slock);
|
|
|
|
spin_unlock(&solo_dev->slock);
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_thread(void *data)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = data;
|
2010-06-18 01:27:26 +08:00
|
|
|
DECLARE_WAITQUEUE(wait, current);
|
|
|
|
|
|
|
|
set_freezable();
|
|
|
|
add_wait_queue(&solo_dev->disp_thread_wait, &wait);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
long timeout = schedule_timeout_interruptible(HZ);
|
2014-07-18 07:40:22 +08:00
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
if (timeout == -ERESTARTSYS || kthread_should_stop())
|
|
|
|
break;
|
2013-03-15 22:56:46 +08:00
|
|
|
solo_thread_try(solo_dev);
|
2010-06-18 01:27:26 +08:00
|
|
|
try_to_freeze();
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_wait_queue(&solo_dev->disp_thread_wait, &wait);
|
|
|
|
|
2010-11-05 10:51:17 +08:00
|
|
|
return 0;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
static int solo_start_thread(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-25 16:35:17 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
solo_dev->kthread = kthread_run(solo_thread, solo_dev, SOLO6X10_NAME "_disp");
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
if (IS_ERR(solo_dev->kthread)) {
|
|
|
|
ret = PTR_ERR(solo_dev->kthread);
|
|
|
|
solo_dev->kthread = NULL;
|
2013-03-15 23:11:17 +08:00
|
|
|
return ret;
|
2013-03-25 16:35:17 +08:00
|
|
|
}
|
2013-03-15 23:11:17 +08:00
|
|
|
solo_irq_on(solo_dev, SOLO_IRQ_VIDEO_IN);
|
2013-03-25 16:35:17 +08:00
|
|
|
|
|
|
|
return ret;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
static void solo_stop_thread(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
if (!solo_dev->kthread)
|
2013-03-25 16:35:17 +08:00
|
|
|
return;
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
solo_irq_off(solo_dev, SOLO_IRQ_VIDEO_IN);
|
2013-03-15 22:56:46 +08:00
|
|
|
kthread_stop(solo_dev->kthread);
|
|
|
|
solo_dev->kthread = NULL;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2015-10-28 10:50:37 +08:00
|
|
|
static int solo_queue_setup(struct vb2_queue *q,
|
2013-03-15 23:11:17 +08:00
|
|
|
unsigned int *num_buffers, unsigned int *num_planes,
|
2016-04-15 20:15:05 +08:00
|
|
|
unsigned int sizes[], struct device *alloc_devs[])
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-15 23:11:17 +08:00
|
|
|
struct solo_dev *solo_dev = vb2_get_drv_priv(q);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
sizes[0] = solo_image_size(solo_dev);
|
|
|
|
*num_planes = 1;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
if (*num_buffers < MIN_VID_BUFFERS)
|
|
|
|
*num_buffers = MIN_VID_BUFFERS;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2010-11-05 10:51:17 +08:00
|
|
|
return 0;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
static int solo_start_streaming(struct vb2_queue *q, unsigned int count)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-15 23:11:17 +08:00
|
|
|
struct solo_dev *solo_dev = vb2_get_drv_priv(q);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-16 00:16:49 +08:00
|
|
|
solo_dev->sequence = 0;
|
2013-03-15 23:11:17 +08:00
|
|
|
return solo_start_thread(solo_dev);
|
|
|
|
}
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2014-04-17 13:47:21 +08:00
|
|
|
static void solo_stop_streaming(struct vb2_queue *q)
|
2013-03-15 23:11:17 +08:00
|
|
|
{
|
|
|
|
struct solo_dev *solo_dev = vb2_get_drv_priv(q);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
solo_stop_thread(solo_dev);
|
|
|
|
INIT_LIST_HEAD(&solo_dev->vidq_active);
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
static void solo_buf_queue(struct vb2_buffer *vb)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
|
2013-03-15 23:11:17 +08:00
|
|
|
struct vb2_queue *vq = vb->vb2_queue;
|
|
|
|
struct solo_dev *solo_dev = vb2_get_drv_priv(vq);
|
|
|
|
struct solo_vb2_buf *solo_vb =
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 21:30:30 +08:00
|
|
|
container_of(vbuf, struct solo_vb2_buf, vb);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
spin_lock(&solo_dev->slock);
|
|
|
|
list_add_tail(&solo_vb->list, &solo_dev->vidq_active);
|
|
|
|
spin_unlock(&solo_dev->slock);
|
2010-06-18 01:27:26 +08:00
|
|
|
wake_up_interruptible(&solo_dev->disp_thread_wait);
|
|
|
|
}
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
static const struct vb2_ops solo_video_qops = {
|
|
|
|
.queue_setup = solo_queue_setup,
|
2010-06-18 01:27:26 +08:00
|
|
|
.buf_queue = solo_buf_queue,
|
2013-03-15 23:11:17 +08:00
|
|
|
.start_streaming = solo_start_streaming,
|
|
|
|
.stop_streaming = solo_stop_streaming,
|
|
|
|
.wait_prepare = vb2_ops_wait_prepare,
|
|
|
|
.wait_finish = vb2_ops_wait_finish,
|
2010-06-18 01:27:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int solo_querycap(struct file *file, void *priv,
|
|
|
|
struct v4l2_capability *cap)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
strcpy(cap->driver, SOLO6X10_NAME);
|
|
|
|
strcpy(cap->card, "Softlogic 6x10");
|
2013-03-13 05:03:20 +08:00
|
|
|
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
|
2010-06-18 01:27:26 +08:00
|
|
|
pci_name(solo_dev->pdev));
|
2013-03-13 05:03:20 +08:00
|
|
|
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
|
|
|
|
V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
|
|
|
|
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
|
2010-06-18 01:27:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
static int solo_enum_ext_input(struct solo_dev *solo_dev,
|
2010-06-18 01:27:26 +08:00
|
|
|
struct v4l2_input *input)
|
|
|
|
{
|
2016-05-05 00:21:21 +08:00
|
|
|
int ext = input->index - solo_dev->nr_chans;
|
|
|
|
unsigned int nup, first;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2016-05-05 00:21:21 +08:00
|
|
|
if (ext >= solo_dev->nr_ext)
|
|
|
|
return -EINVAL;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2016-05-05 00:21:21 +08:00
|
|
|
nup = (ext == 4) ? 16 : 4;
|
|
|
|
first = (ext & 3) << 2; /* first channel in the n-up */
|
|
|
|
snprintf(input->name, sizeof(input->name),
|
|
|
|
"Multi %d-up (cameras %d-%d)",
|
|
|
|
nup, first + 1, first + nup);
|
|
|
|
/* Possible outputs:
|
|
|
|
* Multi 4-up (cameras 1-4)
|
|
|
|
* Multi 4-up (cameras 5-8)
|
|
|
|
* Multi 4-up (cameras 9-12)
|
|
|
|
* Multi 4-up (cameras 13-16)
|
|
|
|
* Multi 16-up (cameras 1-16)
|
|
|
|
*/
|
2010-06-18 01:27:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_enum_input(struct file *file, void *priv,
|
|
|
|
struct v4l2_input *input)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
|
|
|
if (input->index >= solo_dev->nr_chans) {
|
|
|
|
int ret = solo_enum_ext_input(solo_dev, input);
|
2014-07-18 07:40:22 +08:00
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
snprintf(input->name, sizeof(input->name), "Camera %d",
|
|
|
|
input->index + 1);
|
|
|
|
|
|
|
|
/* We can only check this for normal inputs */
|
|
|
|
if (!tw28_get_video_status(solo_dev, input->index))
|
|
|
|
input->status = V4L2_IN_ST_NO_SIGNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
input->type = V4L2_INPUT_TYPE_CAMERA;
|
2013-03-15 23:53:17 +08:00
|
|
|
input->std = solo_dev->vfd->tvnorms;
|
2010-06-18 01:27:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_set_input(struct file *file, void *priv, unsigned int index)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
|
|
|
int ret = solo_v4l2_set_ch(solo_dev, index);
|
2013-03-25 16:35:17 +08:00
|
|
|
|
|
|
|
if (!ret) {
|
2013-03-15 22:56:46 +08:00
|
|
|
while (erase_off(solo_dev))
|
2013-03-25 16:35:17 +08:00
|
|
|
/* Do nothing */;
|
|
|
|
}
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
return ret;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_get_input(struct file *file, void *priv, unsigned int *index)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
*index = solo_dev->cur_disp_ch;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_enum_fmt_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
|
|
|
if (f->index)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
f->pixelformat = V4L2_PIX_FMT_UYVY;
|
|
|
|
strlcpy(f->description, "UYUV 4:2:2 Packed", sizeof(f->description));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_try_fmt_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
2010-06-18 01:27:26 +08:00
|
|
|
struct v4l2_pix_format *pix = &f->fmt.pix;
|
|
|
|
int image_size = solo_image_size(solo_dev);
|
|
|
|
|
2013-03-13 05:43:21 +08:00
|
|
|
if (pix->pixelformat != V4L2_PIX_FMT_UYVY)
|
2010-06-18 01:27:26 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-13 05:43:21 +08:00
|
|
|
pix->width = solo_dev->video_hsize;
|
|
|
|
pix->height = solo_vlines(solo_dev);
|
|
|
|
pix->sizeimage = image_size;
|
|
|
|
pix->field = V4L2_FIELD_INTERLACED;
|
|
|
|
pix->pixelformat = V4L2_PIX_FMT_UYVY;
|
|
|
|
pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
|
|
|
|
pix->priv = 0;
|
2010-06-18 01:27:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_set_fmt_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
if (vb2_is_busy(&solo_dev->vidq))
|
2010-06-18 01:27:26 +08:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
/* For right now, if it doesn't match our running config,
|
|
|
|
* then fail */
|
|
|
|
return solo_try_fmt_cap(file, priv, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_get_fmt_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-03-15 22:56:46 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
2010-06-18 01:27:26 +08:00
|
|
|
struct v4l2_pix_format *pix = &f->fmt.pix;
|
|
|
|
|
|
|
|
pix->width = solo_dev->video_hsize;
|
|
|
|
pix->height = solo_vlines(solo_dev);
|
|
|
|
pix->pixelformat = V4L2_PIX_FMT_UYVY;
|
2013-03-13 05:43:21 +08:00
|
|
|
pix->field = V4L2_FIELD_INTERLACED;
|
2010-06-18 01:27:26 +08:00
|
|
|
pix->sizeimage = solo_image_size(solo_dev);
|
|
|
|
pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
|
|
|
|
pix->bytesperline = solo_bytesperline(solo_dev);
|
2013-03-13 05:43:21 +08:00
|
|
|
pix->priv = 0;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-15 23:53:17 +08:00
|
|
|
static int solo_g_std(struct file *file, void *priv, v4l2_std_id *i)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-15 23:53:17 +08:00
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
|
|
|
|
|
|
|
if (solo_dev->video_type == SOLO_VO_FMT_TYPE_NTSC)
|
|
|
|
*i = V4L2_STD_NTSC_M;
|
|
|
|
else
|
|
|
|
*i = V4L2_STD_PAL;
|
2010-06-18 01:27:26 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-13 17:58:12 +08:00
|
|
|
int solo_set_video_type(struct solo_dev *solo_dev, bool is_50hz)
|
2013-03-15 23:53:17 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Make sure all video nodes are idle */
|
|
|
|
if (vb2_is_busy(&solo_dev->vidq))
|
|
|
|
return -EBUSY;
|
|
|
|
for (i = 0; i < solo_dev->nr_chans; i++)
|
|
|
|
if (vb2_is_busy(&solo_dev->v4l2_enc[i]->vidq))
|
|
|
|
return -EBUSY;
|
2014-01-13 17:58:12 +08:00
|
|
|
solo_dev->video_type = is_50hz ? SOLO_VO_FMT_TYPE_PAL :
|
|
|
|
SOLO_VO_FMT_TYPE_NTSC;
|
2013-03-15 23:53:17 +08:00
|
|
|
/* Reconfigure for the new standard */
|
|
|
|
solo_disp_init(solo_dev);
|
|
|
|
solo_enc_init(solo_dev);
|
|
|
|
solo_tw28_init(solo_dev);
|
|
|
|
for (i = 0; i < solo_dev->nr_chans; i++)
|
|
|
|
solo_update_mode(solo_dev->v4l2_enc[i]);
|
|
|
|
return solo_v4l2_set_ch(solo_dev, solo_dev->cur_disp_ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int solo_s_std(struct file *file, void *priv, v4l2_std_id std)
|
|
|
|
{
|
|
|
|
struct solo_dev *solo_dev = video_drvdata(file);
|
|
|
|
|
2014-01-13 17:58:12 +08:00
|
|
|
return solo_set_video_type(solo_dev, std & V4L2_STD_625_50);
|
2013-03-15 23:53:17 +08:00
|
|
|
}
|
|
|
|
|
2013-03-25 16:38:14 +08:00
|
|
|
static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-25 16:38:14 +08:00
|
|
|
struct solo_dev *solo_dev =
|
|
|
|
container_of(ctrl->handler, struct solo_dev, disp_hdl);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
|
|
|
switch (ctrl->id) {
|
|
|
|
case V4L2_CID_MOTION_TRACE:
|
2013-03-25 16:38:14 +08:00
|
|
|
if (ctrl->val) {
|
2010-06-18 01:27:26 +08:00
|
|
|
solo_reg_write(solo_dev, SOLO_VI_MOTION_BORDER,
|
|
|
|
SOLO_VI_MOTION_Y_ADD |
|
|
|
|
SOLO_VI_MOTION_Y_VALUE(0x20) |
|
|
|
|
SOLO_VI_MOTION_CB_VALUE(0x10) |
|
|
|
|
SOLO_VI_MOTION_CR_VALUE(0x10));
|
|
|
|
solo_reg_write(solo_dev, SOLO_VI_MOTION_BAR,
|
|
|
|
SOLO_VI_MOTION_CR_ADD |
|
|
|
|
SOLO_VI_MOTION_Y_VALUE(0x10) |
|
|
|
|
SOLO_VI_MOTION_CB_VALUE(0x80) |
|
|
|
|
SOLO_VI_MOTION_CR_VALUE(0x10));
|
|
|
|
} else {
|
|
|
|
solo_reg_write(solo_dev, SOLO_VI_MOTION_BORDER, 0);
|
|
|
|
solo_reg_write(solo_dev, SOLO_VI_MOTION_BAR, 0);
|
|
|
|
}
|
|
|
|
return 0;
|
2013-03-25 16:38:14 +08:00
|
|
|
default:
|
|
|
|
break;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct v4l2_file_operations solo_v4l2_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
2013-03-15 22:56:46 +08:00
|
|
|
.open = v4l2_fh_open,
|
2013-03-15 23:11:17 +08:00
|
|
|
.release = vb2_fop_release,
|
|
|
|
.read = vb2_fop_read,
|
|
|
|
.poll = vb2_fop_poll,
|
|
|
|
.mmap = vb2_fop_mmap,
|
|
|
|
.unlocked_ioctl = video_ioctl2,
|
2010-06-18 01:27:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ioctl_ops solo_v4l2_ioctl_ops = {
|
|
|
|
.vidioc_querycap = solo_querycap,
|
|
|
|
.vidioc_s_std = solo_s_std,
|
2013-03-15 23:53:17 +08:00
|
|
|
.vidioc_g_std = solo_g_std,
|
2010-06-18 01:27:26 +08:00
|
|
|
/* Input callbacks */
|
|
|
|
.vidioc_enum_input = solo_enum_input,
|
|
|
|
.vidioc_s_input = solo_set_input,
|
|
|
|
.vidioc_g_input = solo_get_input,
|
|
|
|
/* Video capture format callbacks */
|
|
|
|
.vidioc_enum_fmt_vid_cap = solo_enum_fmt_cap,
|
|
|
|
.vidioc_try_fmt_vid_cap = solo_try_fmt_cap,
|
|
|
|
.vidioc_s_fmt_vid_cap = solo_set_fmt_cap,
|
|
|
|
.vidioc_g_fmt_vid_cap = solo_get_fmt_cap,
|
|
|
|
/* Streaming I/O */
|
2013-03-15 23:11:17 +08:00
|
|
|
.vidioc_reqbufs = vb2_ioctl_reqbufs,
|
|
|
|
.vidioc_querybuf = vb2_ioctl_querybuf,
|
|
|
|
.vidioc_qbuf = vb2_ioctl_qbuf,
|
|
|
|
.vidioc_dqbuf = vb2_ioctl_dqbuf,
|
|
|
|
.vidioc_streamon = vb2_ioctl_streamon,
|
|
|
|
.vidioc_streamoff = vb2_ioctl_streamoff,
|
2013-03-13 05:47:03 +08:00
|
|
|
/* Logging and events */
|
|
|
|
.vidioc_log_status = v4l2_ctrl_log_status,
|
|
|
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2010-06-18 01:27:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct video_device solo_v4l2_template = {
|
2011-02-11 20:38:20 +08:00
|
|
|
.name = SOLO6X10_NAME,
|
2010-06-18 01:27:26 +08:00
|
|
|
.fops = &solo_v4l2_fops,
|
|
|
|
.ioctl_ops = &solo_v4l2_ioctl_ops,
|
|
|
|
.minor = -1,
|
|
|
|
.release = video_device_release,
|
2013-03-15 23:53:17 +08:00
|
|
|
.tvnorms = V4L2_STD_NTSC_M | V4L2_STD_PAL,
|
2010-06-18 01:27:26 +08:00
|
|
|
};
|
|
|
|
|
2013-03-25 16:38:14 +08:00
|
|
|
static const struct v4l2_ctrl_ops solo_ctrl_ops = {
|
|
|
|
.s_ctrl = solo_s_ctrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config solo_motion_trace_ctrl = {
|
|
|
|
.ops = &solo_ctrl_ops,
|
|
|
|
.id = V4L2_CID_MOTION_TRACE,
|
|
|
|
.name = "Motion Detection Trace",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
2013-03-25 16:35:17 +08:00
|
|
|
int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
init_waitqueue_head(&solo_dev->disp_thread_wait);
|
2013-03-15 23:11:17 +08:00
|
|
|
spin_lock_init(&solo_dev->slock);
|
|
|
|
mutex_init(&solo_dev->lock);
|
|
|
|
INIT_LIST_HEAD(&solo_dev->vidq_active);
|
2010-06-18 01:27:26 +08:00
|
|
|
|
|
|
|
solo_dev->vfd = video_device_alloc();
|
|
|
|
if (!solo_dev->vfd)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
*solo_dev->vfd = solo_v4l2_template;
|
2013-03-25 16:36:44 +08:00
|
|
|
solo_dev->vfd->v4l2_dev = &solo_dev->v4l2_dev;
|
2013-03-15 23:11:17 +08:00
|
|
|
solo_dev->vfd->queue = &solo_dev->vidq;
|
|
|
|
solo_dev->vfd->lock = &solo_dev->lock;
|
2013-03-25 16:38:14 +08:00
|
|
|
v4l2_ctrl_handler_init(&solo_dev->disp_hdl, 1);
|
|
|
|
v4l2_ctrl_new_custom(&solo_dev->disp_hdl, &solo_motion_trace_ctrl, NULL);
|
2013-03-15 23:11:17 +08:00
|
|
|
if (solo_dev->disp_hdl.error) {
|
|
|
|
ret = solo_dev->disp_hdl.error;
|
|
|
|
goto fail;
|
|
|
|
}
|
2013-03-25 16:38:14 +08:00
|
|
|
solo_dev->vfd->ctrl_handler = &solo_dev->disp_hdl;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
|
|
|
video_set_drvdata(solo_dev->vfd, solo_dev);
|
|
|
|
|
2013-03-15 23:11:17 +08:00
|
|
|
solo_dev->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
solo_dev->vidq.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
|
|
|
|
solo_dev->vidq.ops = &solo_video_qops;
|
|
|
|
solo_dev->vidq.mem_ops = &vb2_dma_contig_memops;
|
|
|
|
solo_dev->vidq.drv_priv = solo_dev;
|
2014-02-26 06:12:19 +08:00
|
|
|
solo_dev->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
|
2015-11-07 08:28:21 +08:00
|
|
|
solo_dev->vidq.gfp_flags = __GFP_DMA32 | __GFP_KSWAPD_RECLAIM;
|
2013-03-15 23:11:17 +08:00
|
|
|
solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf);
|
|
|
|
solo_dev->vidq.lock = &solo_dev->lock;
|
2016-02-15 22:37:15 +08:00
|
|
|
solo_dev->vidq.dev = &solo_dev->pdev->dev;
|
2013-03-15 23:11:17 +08:00
|
|
|
ret = vb2_queue_init(&solo_dev->vidq);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
/* Cycle all the channels and clear */
|
|
|
|
for (i = 0; i < solo_dev->nr_chans; i++) {
|
|
|
|
solo_v4l2_set_ch(solo_dev, i);
|
|
|
|
while (erase_off(solo_dev))
|
2013-03-25 16:35:17 +08:00
|
|
|
/* Do nothing */;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the default display channel */
|
|
|
|
solo_v4l2_set_ch(solo_dev, 0);
|
|
|
|
while (erase_off(solo_dev))
|
2013-03-25 16:35:17 +08:00
|
|
|
/* Do nothing */;
|
2010-06-18 01:27:26 +08:00
|
|
|
|
2013-03-15 22:56:46 +08:00
|
|
|
ret = video_register_device(solo_dev->vfd, VFL_TYPE_GRABBER, nr);
|
2013-03-15 23:11:17 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2013-03-15 22:56:46 +08:00
|
|
|
|
|
|
|
snprintf(solo_dev->vfd->name, sizeof(solo_dev->vfd->name), "%s (%i)",
|
|
|
|
SOLO6X10_NAME, solo_dev->vfd->num);
|
|
|
|
|
[media] solo6x10: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-19 03:44:07 +08:00
|
|
|
dev_info(&solo_dev->pdev->dev, "Display as /dev/video%d with %d inputs (%d extended)\n",
|
|
|
|
solo_dev->vfd->num,
|
2013-03-15 22:56:46 +08:00
|
|
|
solo_dev->nr_chans, solo_dev->nr_ext);
|
|
|
|
|
2010-06-18 01:27:26 +08:00
|
|
|
return 0;
|
2013-03-15 23:11:17 +08:00
|
|
|
|
|
|
|
fail:
|
|
|
|
video_device_release(solo_dev->vfd);
|
|
|
|
v4l2_ctrl_handler_free(&solo_dev->disp_hdl);
|
|
|
|
solo_dev->vfd = NULL;
|
|
|
|
return ret;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:38:20 +08:00
|
|
|
void solo_v4l2_exit(struct solo_dev *solo_dev)
|
2010-06-18 01:27:26 +08:00
|
|
|
{
|
2013-03-25 16:35:17 +08:00
|
|
|
if (solo_dev->vfd == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
video_unregister_device(solo_dev->vfd);
|
2013-03-25 16:38:14 +08:00
|
|
|
v4l2_ctrl_handler_free(&solo_dev->disp_hdl);
|
2013-03-25 16:35:17 +08:00
|
|
|
solo_dev->vfd = NULL;
|
2010-06-18 01:27:26 +08:00
|
|
|
}
|