V4L/DVB (5329): Some saa7134 cleanups
- use generic sort instead of bubblesort - removed useless saa7134_video_fini function - small coding style changes Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
80f90fba3e
commit
9040b32ea3
|
@ -734,7 +734,6 @@ static int saa7134_hwfini(struct saa7134_dev *dev)
|
||||||
saa7134_ts_fini(dev);
|
saa7134_ts_fini(dev);
|
||||||
saa7134_input_fini(dev);
|
saa7134_input_fini(dev);
|
||||||
saa7134_vbi_fini(dev);
|
saa7134_vbi_fini(dev);
|
||||||
saa7134_video_fini(dev);
|
|
||||||
saa7134_tvaudio_fini(dev);
|
saa7134_tvaudio_fini(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/sort.h>
|
||||||
|
|
||||||
#include "saa7134-reg.h"
|
#include "saa7134-reg.h"
|
||||||
#include "saa7134.h"
|
#include "saa7134.h"
|
||||||
|
@ -516,14 +517,12 @@ static int res_get(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int res_check(struct saa7134_fh *fh, unsigned int bit)
|
||||||
int res_check(struct saa7134_fh *fh, unsigned int bit)
|
|
||||||
{
|
{
|
||||||
return (fh->resources & bit);
|
return (fh->resources & bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static int res_locked(struct saa7134_dev *dev, unsigned int bit)
|
||||||
int res_locked(struct saa7134_dev *dev, unsigned int bit)
|
|
||||||
{
|
{
|
||||||
return (dev->resources & bit);
|
return (dev->resources & bit);
|
||||||
}
|
}
|
||||||
|
@ -739,25 +738,6 @@ struct cliplist {
|
||||||
__u8 disable;
|
__u8 disable;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void sort_cliplist(struct cliplist *cl, int entries)
|
|
||||||
{
|
|
||||||
struct cliplist swap;
|
|
||||||
int i,j,n;
|
|
||||||
|
|
||||||
for (i = entries-2; i >= 0; i--) {
|
|
||||||
for (n = 0, j = 0; j <= i; j++) {
|
|
||||||
if (cl[j].position > cl[j+1].position) {
|
|
||||||
swap = cl[j];
|
|
||||||
cl[j] = cl[j+1];
|
|
||||||
cl[j+1] = swap;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (0 == n)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_cliplist(struct saa7134_dev *dev, int reg,
|
static void set_cliplist(struct saa7134_dev *dev, int reg,
|
||||||
struct cliplist *cl, int entries, char *name)
|
struct cliplist *cl, int entries, char *name)
|
||||||
{
|
{
|
||||||
|
@ -791,15 +771,27 @@ static int clip_range(int val)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sort into smallest position first order */
|
||||||
|
static int cliplist_cmp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const struct cliplist *cla = a;
|
||||||
|
const struct cliplist *clb = b;
|
||||||
|
if (cla->position < clb->position)
|
||||||
|
return -1;
|
||||||
|
if (cla->position > clb->position)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips,
|
static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips,
|
||||||
int nclips, int interlace)
|
int nclips, int interlace)
|
||||||
{
|
{
|
||||||
struct cliplist col[16], row[16];
|
struct cliplist col[16], row[16];
|
||||||
int cols, rows, i;
|
int cols = 0, rows = 0, i;
|
||||||
int div = interlace ? 2 : 1;
|
int div = interlace ? 2 : 1;
|
||||||
|
|
||||||
memset(col,0,sizeof(col)); cols = 0;
|
memset(col, 0, sizeof(col));
|
||||||
memset(row,0,sizeof(row)); rows = 0;
|
memset(row, 0, sizeof(row));
|
||||||
for (i = 0; i < nclips && i < 8; i++) {
|
for (i = 0; i < nclips && i < 8; i++) {
|
||||||
col[cols].position = clip_range(clips[i].c.left);
|
col[cols].position = clip_range(clips[i].c.left);
|
||||||
col[cols].enable = (1 << i);
|
col[cols].enable = (1 << i);
|
||||||
|
@ -815,8 +807,8 @@ static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips,
|
||||||
row[rows].disable = (1 << i);
|
row[rows].disable = (1 << i);
|
||||||
rows++;
|
rows++;
|
||||||
}
|
}
|
||||||
sort_cliplist(col,cols);
|
sort(col, cols, sizeof col[0], cliplist_cmp, NULL);
|
||||||
sort_cliplist(row,rows);
|
sort(row, rows, sizeof row[0], cliplist_cmp, NULL);
|
||||||
set_cliplist(dev,0x380,col,cols,"cols");
|
set_cliplist(dev,0x380,col,cols,"cols");
|
||||||
set_cliplist(dev,0x384,row,rows,"rows");
|
set_cliplist(dev,0x384,row,rows,"rows");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1268,19 +1260,14 @@ static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh)
|
||||||
|
|
||||||
static int saa7134_resource(struct saa7134_fh *fh)
|
static int saa7134_resource(struct saa7134_fh *fh)
|
||||||
{
|
{
|
||||||
int res = 0;
|
if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||||
|
return RESOURCE_VIDEO;
|
||||||
|
|
||||||
switch (fh->type) {
|
if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)
|
||||||
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
return RESOURCE_VBI;
|
||||||
res = RESOURCE_VIDEO;
|
|
||||||
break;
|
BUG();
|
||||||
case V4L2_BUF_TYPE_VBI_CAPTURE:
|
return 0;
|
||||||
res = RESOURCE_VBI;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BUG();
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int video_open(struct inode *inode, struct file *file)
|
static int video_open(struct inode *inode, struct file *file)
|
||||||
|
@ -1468,8 +1455,7 @@ static int video_release(struct inode *inode, struct file *file)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int video_mmap(struct file *file, struct vm_area_struct * vma)
|
||||||
video_mmap(struct file *file, struct vm_area_struct * vma)
|
|
||||||
{
|
{
|
||||||
struct saa7134_fh *fh = file->private_data;
|
struct saa7134_fh *fh = file->private_data;
|
||||||
|
|
||||||
|
@ -2468,12 +2454,6 @@ int saa7134_video_init2(struct saa7134_dev *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int saa7134_video_fini(struct saa7134_dev *dev)
|
|
||||||
{
|
|
||||||
/* nothing */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saa7134_irq_video_intl(struct saa7134_dev *dev)
|
void saa7134_irq_video_intl(struct saa7134_dev *dev)
|
||||||
{
|
{
|
||||||
static const char *st[] = {
|
static const char *st[] = {
|
||||||
|
|
|
@ -626,7 +626,6 @@ int saa7134_common_ioctl(struct saa7134_dev *dev,
|
||||||
|
|
||||||
int saa7134_video_init1(struct saa7134_dev *dev);
|
int saa7134_video_init1(struct saa7134_dev *dev);
|
||||||
int saa7134_video_init2(struct saa7134_dev *dev);
|
int saa7134_video_init2(struct saa7134_dev *dev);
|
||||||
int saa7134_video_fini(struct saa7134_dev *dev);
|
|
||||||
void saa7134_irq_video_intl(struct saa7134_dev *dev);
|
void saa7134_irq_video_intl(struct saa7134_dev *dev);
|
||||||
void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
|
void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue