V4L/DVB (10930): zoran: Unify buffer descriptors

The zoran driver had two kinds of buffer descriptors, one for jpg buffers
and one for raw buffers.  They were mostly the same with only a couple

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Trent Piepho 2009-03-10 23:28:16 -03:00 committed by Mauro Carvalho Chehab
parent ce904bcba4
commit 1159b7f19f
3 changed files with 393 additions and 521 deletions

View File

@ -172,6 +172,8 @@ Private IOCTL to set up for displaying MJPEG
#endif #endif
#define V4L_MASK_FRAME (V4L_MAX_FRAME - 1) #define V4L_MASK_FRAME (V4L_MAX_FRAME - 1)
#define MAX_FRAME (BUZ_MAX_FRAME > VIDEO_MAX_FRAME ? BUZ_MAX_FRAME : VIDEO_MAX_FRAME)
#include "zr36057.h" #include "zr36057.h"
enum card_type { enum card_type {
@ -280,21 +282,21 @@ struct zoran_mapping {
int count; int count;
}; };
struct zoran_jpg_buffer { struct zoran_buffer {
struct zoran_mapping *map; struct zoran_mapping *map;
__le32 *frag_tab; /* addresses of frag table */ enum zoran_buffer_state state; /* state: unused/pending/dma/done */
u32 frag_tab_bus; /* same value cached to save time in ISR */ struct zoran_sync bs; /* DONE: info to return to application */
enum zoran_buffer_state state; /* non-zero if corresponding buffer is in use in grab queue */ union {
struct zoran_sync bs; /* DONE: info to return to application */ struct {
}; __le32 *frag_tab; /* addresses of frag table */
u32 frag_tab_bus; /* same value cached to save time in ISR */
struct zoran_v4l_buffer { } jpg;
struct zoran_mapping *map; struct {
char *fbuffer; /* virtual address of frame buffer */ char *fbuffer; /* virtual address of frame buffer */
unsigned long fbuffer_phys; /* physical address of frame buffer */ unsigned long fbuffer_phys;/* physical address of frame buffer */
unsigned long fbuffer_bus; /* bus address of frame buffer */ unsigned long fbuffer_bus;/* bus address of frame buffer */
enum zoran_buffer_state state; /* state: unused/pending/done */ } v4l;
struct zoran_sync bs; /* DONE: info to return to application */ };
}; };
enum zoran_lock_activity { enum zoran_lock_activity {
@ -304,19 +306,13 @@ enum zoran_lock_activity {
}; };
/* buffer collections */ /* buffer collections */
struct zoran_jpg_struct { struct zoran_buffer_col {
enum zoran_lock_activity active; /* feature currently in use? */ enum zoran_lock_activity active; /* feature currently in use? */
struct zoran_jpg_buffer buffer[BUZ_MAX_FRAME]; /* buffers */ unsigned int num_buffers, buffer_size;
int num_buffers, buffer_size; struct zoran_buffer buffer[MAX_FRAME]; /* buffers */
u8 allocated; /* Flag if buffers are allocated */ u8 allocated; /* Flag if buffers are allocated */
u8 need_contiguous; /* Flag if contiguous buffers are needed */ u8 need_contiguous; /* Flag if contiguous buffers are needed */
}; /* only applies to jpg buffers, raw buffers are always contiguous */
struct zoran_v4l_struct {
enum zoran_lock_activity active; /* feature currently in use? */
struct zoran_v4l_buffer buffer[VIDEO_MAX_FRAME]; /* buffers */
int num_buffers, buffer_size;
u8 allocated; /* Flag if buffers are allocated */
}; };
struct zoran; struct zoran;
@ -325,17 +321,16 @@ struct zoran;
struct zoran_fh { struct zoran_fh {
struct zoran *zr; struct zoran *zr;
enum zoran_map_mode map_mode; /* Flag which bufferset will map by next mmap() */ enum zoran_map_mode map_mode; /* Flag which bufferset will map by next mmap() */
struct zoran_overlay_settings overlay_settings; struct zoran_overlay_settings overlay_settings;
u32 *overlay_mask; /* overlay mask */ u32 *overlay_mask; /* overlay mask */
enum zoran_lock_activity overlay_active; /* feature currently in use? */ enum zoran_lock_activity overlay_active;/* feature currently in use? */
struct zoran_buffer_col buffers; /* buffers' info */
struct zoran_v4l_settings v4l_settings; /* structure with a lot of things to play with */ struct zoran_v4l_settings v4l_settings; /* structure with a lot of things to play with */
struct zoran_v4l_struct v4l_buffers; /* V4L buffers' info */
struct zoran_jpg_settings jpg_settings; /* structure with a lot of things to play with */ struct zoran_jpg_settings jpg_settings; /* structure with a lot of things to play with */
struct zoran_jpg_struct jpg_buffers; /* MJPEG buffers' info */
}; };
struct card_info { struct card_info {
@ -434,7 +429,7 @@ struct zoran {
unsigned long v4l_pend_tail; unsigned long v4l_pend_tail;
unsigned long v4l_sync_tail; unsigned long v4l_sync_tail;
int v4l_pend[V4L_MAX_FRAME]; int v4l_pend[V4L_MAX_FRAME];
struct zoran_v4l_struct v4l_buffers; /* V4L buffers' info */ struct zoran_buffer_col v4l_buffers; /* V4L buffers' info */
/* Buz MJPEG parameters */ /* Buz MJPEG parameters */
enum zoran_codec_mode codec_mode; /* status of codec */ enum zoran_codec_mode codec_mode; /* status of codec */
@ -461,7 +456,7 @@ struct zoran {
int jpg_pend[BUZ_MAX_FRAME]; int jpg_pend[BUZ_MAX_FRAME];
/* array indexed by frame number */ /* array indexed by frame number */
struct zoran_jpg_struct jpg_buffers; /* MJPEG buffers' info */ struct zoran_buffer_col jpg_buffers; /* MJPEG buffers' info */
/* Additional stuff for testing */ /* Additional stuff for testing */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS

View File

@ -1125,7 +1125,7 @@ zoran_feed_stat_com (struct zoran *zr)
if (!(zr->stat_com[i] & cpu_to_le32(1))) if (!(zr->stat_com[i] & cpu_to_le32(1)))
break; break;
zr->stat_com[i] = zr->stat_com[i] =
cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus); cpu_to_le32(zr->jpg_buffers.buffer[frame].jpg.frag_tab_bus);
} else { } else {
/* fill 2 stat_com entries */ /* fill 2 stat_com entries */
i = ((zr->jpg_dma_head - i = ((zr->jpg_dma_head -
@ -1133,9 +1133,9 @@ zoran_feed_stat_com (struct zoran *zr)
if (!(zr->stat_com[i] & cpu_to_le32(1))) if (!(zr->stat_com[i] & cpu_to_le32(1)))
break; break;
zr->stat_com[i] = zr->stat_com[i] =
cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus); cpu_to_le32(zr->jpg_buffers.buffer[frame].jpg.frag_tab_bus);
zr->stat_com[i + 1] = zr->stat_com[i + 1] =
cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus); cpu_to_le32(zr->jpg_buffers.buffer[frame].jpg.frag_tab_bus);
} }
zr->jpg_buffers.buffer[frame].state = BUZ_STATE_DMA; zr->jpg_buffers.buffer[frame].state = BUZ_STATE_DMA;
zr->jpg_dma_head++; zr->jpg_dma_head++;
@ -1155,7 +1155,7 @@ zoran_reap_stat_com (struct zoran *zr)
u32 stat_com; u32 stat_com;
unsigned int seq; unsigned int seq;
unsigned int dif; unsigned int dif;
struct zoran_jpg_buffer *buffer; struct zoran_buffer *buffer;
int frame; int frame;
/* In motion decompress we don't have a hardware frame counter, /* In motion decompress we don't have a hardware frame counter,
@ -1298,7 +1298,7 @@ error_handler (struct zoran *zr,
printk(KERN_INFO "stat_com frames:"); printk(KERN_INFO "stat_com frames:");
for (j = 0; j < BUZ_NUM_STAT_COM; j++) { for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
for (i = 0; i < zr->jpg_buffers.num_buffers; i++) { for (i = 0; i < zr->jpg_buffers.num_buffers; i++) {
if (le32_to_cpu(zr->stat_com[j]) == zr->jpg_buffers.buffer[i].frag_tab_bus) if (le32_to_cpu(zr->stat_com[j]) == zr->jpg_buffers.buffer[i].jpg.frag_tab_bus)
printk(KERN_CONT "% d->%d", j, i); printk(KERN_CONT "% d->%d", j, i);
} }
} }
@ -1437,7 +1437,7 @@ zoran_irq (int irq,
/* Buffer address */ /* Buffer address */
reg = zr->v4l_buffers.buffer[frame].fbuffer_bus; reg = zr->v4l_buffers.buffer[frame].v4l.fbuffer_bus;
btwrite(reg, ZR36057_VDTR); btwrite(reg, ZR36057_VDTR);
if (zr->v4l_settings.height > BUZ_MAX_HEIGHT / 2) if (zr->v4l_settings.height > BUZ_MAX_HEIGHT / 2)
reg += zr->v4l_settings.bytesperline; reg += zr->v4l_settings.bytesperline;

File diff suppressed because it is too large Load Diff