V4L/DVB: cx25821: Removed duplicate code and cleaned up

Signed-off-by: Palash Bandyopadhyay <Palash.Bandyopadhyay@conexant.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h
index cf2286d..1b628f6 100644
--- a/drivers/staging/cx25821/cx25821.h
+++ b/drivers/staging/cx25821/cx25821.h
@@ -61,7 +61,7 @@
 #define FALSE   0
 #define LINE_SIZE_D1    1440
 
-// Number of decoders and encoders
+/* Number of decoders and encoders */
 #define MAX_DECODERS            8
 #define MAX_ENCODERS            2
 #define QUAD_DECODERS           4
@@ -139,6 +139,7 @@
 	/* video capture */
 	struct cx25821_fmt *fmt;
 	unsigned int width, height;
+    int channel_id;
 
 	/* vbi capture */
 	struct videobuf_queue vidq;
@@ -236,13 +237,34 @@
 	struct sram_channel *channel;
 };
 
+struct cx25821_channel {
+       struct v4l2_prio_state prio;
+
+       int ctl_bright;
+       int ctl_contrast;
+       int ctl_hue;
+       int ctl_saturation;
+
+       struct cx25821_data timeout_data;
+
+       struct video_device *video_dev;
+       struct cx25821_dmaqueue vidq;
+
+       struct sram_channel *sram_channels;
+
+       struct mutex lock;
+       int resources;
+
+       int pixel_formats;
+       int use_cif_resolution;
+       int cif_width;
+};
+
 struct cx25821_dev {
 	struct list_head devlist;
 	atomic_t refcount;
 	struct v4l2_device v4l2_dev;
 
-	struct v4l2_prio_state prio;
-
 	/* pci stuff */
 	struct pci_dev *pci;
 	unsigned char pci_rev, pci_lat;
@@ -261,13 +283,12 @@
 	int nr;
 	struct mutex lock;
 
+    struct cx25821_channel channels[MAX_VID_CHANNEL_NUM];
+
 	/* board details */
 	unsigned int board;
 	char name[32];
 
-	/* sram configuration */
-	struct sram_channel *sram_channels;
-
 	/* Analog video */
 	u32 resources;
 	unsigned int input;
@@ -282,13 +303,6 @@
 	unsigned char videc_addr;
 	unsigned short _max_num_decoders;
 
-	int ctl_bright;
-	int ctl_contrast;
-	int ctl_hue;
-	int ctl_saturation;
-
-	struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
-
 	/* Analog Audio Upstream */
 	int _audio_is_running;
 	int _audiopixel_format;
@@ -297,7 +311,7 @@
 	int _audio_lines_count;
 	int _audioframe_count;
 	int _audio_upstream_channel_select;
-	int _last_index_irq;	//The last interrupt index processed.
+       int _last_index_irq;    /* The last interrupt index processed. */
 
 	__le32 *_risc_audio_jmp_addr;
 	__le32 *_risc_virt_start_addr;
@@ -313,12 +327,10 @@
 
 	/* V4l */
 	u32 freq;
-	struct video_device *video_dev[MAX_VID_CHANNEL_NUM];
 	struct video_device *vbi_dev;
 	struct video_device *radio_dev;
 	struct video_device *ioctl_dev;
 
-	struct cx25821_dmaqueue vidq[MAX_VID_CHANNEL_NUM];
 	spinlock_t slock;
 
 	/* Video Upstream */
@@ -401,9 +413,6 @@
 	int pixel_format;
 	int channel_select;
 	int command;
-	int pixel_formats[VID_CHANNEL_NUM];
-	int use_cif_resolution[VID_CHANNEL_NUM];
-	int cif_width[VID_CHANNEL_NUM];
 	int channel_opened;
 };
 
@@ -482,7 +491,7 @@
 	u32 fld_aud_fifo_en;
 	u32 fld_aud_risc_en;
 
-	//For Upstream Video
+       /* For Upstream Video */
 	u32 vid_fmt_ctl;
 	u32 vid_active_ctl1;
 	u32 vid_active_ctl2;