summaryrefslogtreecommitdiff
path: root/v4l2-apps/util/cx25821
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-09-17 11:17:44 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-17 11:17:44 -0300
commitee117cb21fc99d6d1ef141b62ac07c2c99ed6558 (patch)
treeb3109826151f5b2cacd01a2a78fc51079381fec7 /v4l2-apps/util/cx25821
parent3c34c6c8fa0c2f378cdad415e8f15c0938c28cb8 (diff)
parent26642526dd562aa77049bb56d5bf9ad64158c767 (diff)
downloadmediapointer-dvb-s2-ee117cb21fc99d6d1ef141b62ac07c2c99ed6558.tar.gz
mediapointer-dvb-s2-ee117cb21fc99d6d1ef141b62ac07c2c99ed6558.tar.bz2
merge: http://kernellabs.com/hg/~mkrufky/saa7164
From: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'v4l2-apps/util/cx25821')
-rw-r--r--v4l2-apps/util/cx25821/audioplayback1
-rw-r--r--v4l2-apps/util/cx25821/audiorecord1
-rw-r--r--v4l2-apps/util/cx25821/cx25821-medusa-decoder.c106
-rw-r--r--v4l2-apps/util/cx25821/medusaReadWrite.c158
-rw-r--r--v4l2-apps/util/cx25821/mencode_av1
-rw-r--r--v4l2-apps/util/cx25821/mencode_video1
-rw-r--r--v4l2-apps/util/cx25821/mplay_av1
-rw-r--r--v4l2-apps/util/cx25821/mplay_cifNTSC1
-rw-r--r--v4l2-apps/util/cx25821/mplay_cifPAL1
-rw-r--r--v4l2-apps/util/cx25821/mplay_video1
-rw-r--r--v4l2-apps/util/cx25821/regReadWrite.c158
-rw-r--r--v4l2-apps/util/cx25821/setAlsaVolume2
-rw-r--r--v4l2-apps/util/cx25821/setvideosetting.c187
-rw-r--r--v4l2-apps/util/cx25821/upstream_app.c221
14 files changed, 840 insertions, 0 deletions
diff --git a/v4l2-apps/util/cx25821/audioplayback b/v4l2-apps/util/cx25821/audioplayback
new file mode 100644
index 000000000..1b09da915
--- /dev/null
+++ b/v4l2-apps/util/cx25821/audioplayback
@@ -0,0 +1 @@
+aplay -c 2 -r 48000 -f S16_LE $1
diff --git a/v4l2-apps/util/cx25821/audiorecord b/v4l2-apps/util/cx25821/audiorecord
new file mode 100644
index 000000000..ee2c46650
--- /dev/null
+++ b/v4l2-apps/util/cx25821/audiorecord
@@ -0,0 +1 @@
+arecord -D hw:1,0 -d $2 -c 2 -r 48000 -f S16_LE > $1
diff --git a/v4l2-apps/util/cx25821/cx25821-medusa-decoder.c b/v4l2-apps/util/cx25821/cx25821-medusa-decoder.c
new file mode 100644
index 000000000..7bd35ed43
--- /dev/null
+++ b/v4l2-apps/util/cx25821/cx25821-medusa-decoder.c
@@ -0,0 +1,106 @@
+/*
+ * Driver for the Conexant CX25821 PCIe bridge
+ *
+ * Copyright (C) 2009 Conexant Systems Inc.
+ * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "cx25821.h"
+
+
+// Array for GPIO selected bits for a specific decoder.
+
+enum GPIO_DEF { DECA_SEL = 0,
+ DECB_SEL,
+ DECC_SEL,
+ DECD_SEL,
+ MON_SEL = 4};
+
+enum GPIO_OCTAL_DEF { OCTAL_DECA_SEL = 0,
+ OCTAL_DECB_SEL,
+ OCTAL_DECC_SEL,
+ OCTAL_DECD_SEL,
+ OCTAL_DECE_SEL,
+ OCTAL_DECF_SEL,
+ OCTAL_DECG_SEL,
+ OCTAL_DECH_SEL,
+ OCTAL_MON_SEL = 8 };
+
+
+// Direction bits are at offset 23:16
+#define Set_GPIO_Direction_Bit_To_OUTPUT(Bit) ((1 << Bit) << 16)
+
+struct medusa_decoder {
+ int _cur_dec;
+ unsigned short _num_vdec;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Selects Medusa Decoder Channel.
+////////////////////////////////////////////////////////////////////////////////////////
+void medusa_decoder_select(struct cx25821_dev *dev, struct medusa_decoder *dec, int decoder)
+{
+
+ if (decoder < DECA_SEL && decoder > MON_SEL )
+ return;
+
+ dec->_cur_dec = decoder;
+
+ u32 gpioRegister = cx_read(GP0_IO);
+ u32 value = (gpioRegister & 0xFFFFFFF0) | dec->_cur_dec;
+ cx_write( GP0_IO, value );
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Sets the GPIO pin directions
+// Parameters:
+//
+////////////////////////////////////////////////////////////////////////////////////////
+void medusa_video_set_gpiopin_directions_to_output(struct cx25821_dev *dev, struct medusa_decoder *dec )
+{
+ // Here we will make sure that the GPIOs 0-3 are output. keep the rest as is
+ u32 gpioRegister = cx_read( GP0_IO );
+
+ // This operation will set the GPIO bits below.
+ if (dec->_num_vdec == 4)
+ {
+ cx_write( GP0_IO,
+ gpioRegister
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(DECA_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(DECB_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(DECC_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(DECD_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(MON_SEL)) );
+ medusa_decoder_select(dev, dec, MON_SEL);
+ }
+ else
+ {
+ cx_write( GP0_IO,
+ gpioRegister
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECA_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECB_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECC_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECD_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECE_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECF_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECG_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_DECH_SEL))
+ | (Set_GPIO_Direction_Bit_To_OUTPUT(OCTAL_MON_SEL)) );
+ medusa_decoder_select(dev, dec, OCTAL_MON_SEL);
+ }
+}
diff --git a/v4l2-apps/util/cx25821/medusaReadWrite.c b/v4l2-apps/util/cx25821/medusaReadWrite.c
new file mode 100644
index 000000000..cf4a1a5e6
--- /dev/null
+++ b/v4l2-apps/util/cx25821/medusaReadWrite.c
@@ -0,0 +1,158 @@
+/*
+ * Driver for the Conexant CX25821 PCIe bridge
+ *
+ * Copyright (C) 2009 Conexant Systems Inc.
+ * Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <linux/errno.h>
+#include <linux/ioctl.h>
+
+
+#define MEDUSA_READ 910
+#define MEDUSA_WRITE 911
+
+typedef struct{
+ char *vid_stdname;
+ int pixel_format;
+ int cif_resolution_enable;
+ int cif_width;
+ int decoder_select;
+ int command;
+ int reg_address;
+ int reg_data;
+}downstream_user_struct;
+
+
+void print_usage()
+{
+ printf("\n*********************************\n");
+ printf("Sample Usage: ./medusa d 1 r 0x01\n");
+ printf("Sample Usage: ./medusa d 1 w 0x0 0x2\n");
+ printf(" d device_id Device ID (1 and above) for MultiCard\n");
+ printf(" r Read Medusa register\n");
+ printf(" w Write Medusa register\n");
+}
+
+int main(int argc, char** argv)
+{
+ unsigned int cmd= 0 ;
+ int fp;
+ int i = 1, j = 0, k = 0, len = 0;
+ int mode = 0;
+
+ int register_addr = 0;
+ int write_value = 0;
+
+ int device_id = 0, video_id = 11;
+ char * temp2;
+ char *device_str[4] = {"/dev/video11", "/dev/video23", "/dev/video35", "/dev/video47"};
+
+ char mode_temp = 's';
+ char *param_temp;
+
+
+ if(argc < 5 || (tolower(*(argv[1])) != 'd') )
+ {
+ print_usage();
+ return -EINVAL;
+ }
+
+ sscanf(argv[2], "%d", &device_id );
+ i += 2;
+
+ if( device_id <= 0 || device_id > 4 )
+ {
+ print_usage();
+ return -EINVAL;
+ }
+
+ printf("\n********************************* \n");
+
+ if((fp = open(device_str[device_id-1], O_RDWR)) == -1)
+ {
+ printf("Error: cannot open device file %s !\n", device_str[device_id-1]);
+ return -EINVAL;
+ }
+
+ printf("Device %s open for IOCTL successfully!\n", device_str[device_id-1]);
+
+
+ for( ; i < argc; i++)
+ {
+ temp2 = argv[i];
+ mode_temp = tolower(temp2[0]);
+ param_temp = argv[i+1];
+
+
+ switch(mode_temp)
+ {
+ case 'r':
+ {
+ downstream_user_struct arguments;
+
+ sscanf(param_temp, "%x", &register_addr );
+
+ arguments.reg_address = register_addr;
+ arguments.command = MEDUSA_READ;
+
+ printf("Read parameters: read register = 0x%x, command = %d \n", arguments.reg_address, arguments.command);
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ printf("Reg 0x%x = 0x%x\n", arguments.reg_address, arguments.reg_data);
+ }
+ break;
+
+ case 'w':
+ {
+ downstream_user_struct arguments;
+
+ sscanf(param_temp, "%x", &register_addr );
+ sscanf(argv[i+2], "%x", &write_value );
+ i++;
+
+ arguments.command = MEDUSA_WRITE;
+ arguments.reg_address = register_addr;
+ arguments.reg_data = write_value;
+
+ printf("Write parameters: write register = 0x%x, write_value = 0x%x, command = %d \n", arguments.reg_address, arguments.reg_data, arguments.command);
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ }
+ break;
+
+ default:
+ printf("Please verify the options are correct!\n");
+ break;
+ }
+
+ i++;
+ }
+
+
+ printf("********************************* \n\n");
+ close(fp);
+ return 0;
+}
+
diff --git a/v4l2-apps/util/cx25821/mencode_av b/v4l2-apps/util/cx25821/mencode_av
new file mode 100644
index 000000000..6533cb4d8
--- /dev/null
+++ b/v4l2-apps/util/cx25821/mencode_av
@@ -0,0 +1 @@
+mencoder tv:// -tv driver=v4l2:input=0:norm=ntsc:width=720:height=480:outfmt=yuy2:device=/dev/video$1:forceaudio:alsa=1:adevice=hw.1:audiorate=48000:immediatemode=0:amode=1 buffersize=64 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000:keyint=30 -oac mp3lame -lameopts br=128:cbr:mode=3 -ffourcc divx -o $2 \ No newline at end of file
diff --git a/v4l2-apps/util/cx25821/mencode_video b/v4l2-apps/util/cx25821/mencode_video
new file mode 100644
index 000000000..9f0c29ebd
--- /dev/null
+++ b/v4l2-apps/util/cx25821/mencode_video
@@ -0,0 +1 @@
+mencoder tv:// -tv driver=v4l2:input=0:norm=ntsc:width=720:height=480:outfmt=yuy2:device=/dev/video$1 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=5000:keyint=30 -nosound -ffourcc divx -o $2
diff --git a/v4l2-apps/util/cx25821/mplay_av b/v4l2-apps/util/cx25821/mplay_av
new file mode 100644
index 000000000..0b11e7af6
--- /dev/null
+++ b/v4l2-apps/util/cx25821/mplay_av
@@ -0,0 +1 @@
+mplayer -vo x11 -tv driver=v4l2:device=/dev/video$1:input=1:norm=NTSC-M:width=720:height=480:outfmt=yuy2:alsa=1:adevice=hw.1:audiorate=48000:immediatemode=0:amode=1 tv:///0
diff --git a/v4l2-apps/util/cx25821/mplay_cifNTSC b/v4l2-apps/util/cx25821/mplay_cifNTSC
new file mode 100644
index 000000000..ba3c34ec2
--- /dev/null
+++ b/v4l2-apps/util/cx25821/mplay_cifNTSC
@@ -0,0 +1 @@
+mplayer -vo x11 -tv driver=v4l2:device=/dev/video$1:input=1:norm=NTSC-M:width=320:height=240:outfmt=yuy2: tv:///0
diff --git a/v4l2-apps/util/cx25821/mplay_cifPAL b/v4l2-apps/util/cx25821/mplay_cifPAL
new file mode 100644
index 000000000..2139ffb0a
--- /dev/null
+++ b/v4l2-apps/util/cx25821/mplay_cifPAL
@@ -0,0 +1 @@
+mplayer -vo x11 -tv driver=v4l2:device=/dev/video$1:input=1:norm=PAL-BG:width=352:height=288:outfmt=yuy2: tv:///0
diff --git a/v4l2-apps/util/cx25821/mplay_video b/v4l2-apps/util/cx25821/mplay_video
new file mode 100644
index 000000000..7d9567662
--- /dev/null
+++ b/v4l2-apps/util/cx25821/mplay_video
@@ -0,0 +1 @@
+mplayer -vo x11 -tv driver=v4l2:device=/dev/video$1:input=1:norm=NTSC-M:width=720:height=480:outfmt=yuy2: tv:///0
diff --git a/v4l2-apps/util/cx25821/regReadWrite.c b/v4l2-apps/util/cx25821/regReadWrite.c
new file mode 100644
index 000000000..2d506183d
--- /dev/null
+++ b/v4l2-apps/util/cx25821/regReadWrite.c
@@ -0,0 +1,158 @@
+/*
+ * Driver for the Conexant CX25821 PCIe bridge
+ *
+ * Copyright (C) 2009 Conexant Systems Inc.
+ * Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <linux/errno.h>
+#include <linux/ioctl.h>
+
+
+#define REG_READ 900
+#define REG_WRITE 901
+
+typedef struct{
+ char *vid_stdname;
+ int pixel_format;
+ int cif_resolution_enable;
+ int cif_width;
+ int decoder_select;
+ int command;
+ int reg_address;
+ int reg_data;
+}downstream_user_struct;
+
+
+void print_usage()
+{
+ printf("\n*********************************\n");
+ printf("Sample Usage: ./reg d 1 r 0x01\n");
+ printf("Sample Usage: ./reg d 1 w 0x0 0x2\n");
+ printf(" d device_id Device ID (1 and above) for MultiCard\n");
+ printf(" r Read Athena register\n");
+ printf(" w Write Athena register\n");
+}
+
+int main(int argc, char** argv)
+{
+ unsigned int cmd= 0 ;
+ int fp;
+ int i = 1, j = 0, k = 0, len = 0;
+ int mode = 0;
+
+ int register_addr = 0;
+ int write_value = 0;
+
+ int device_id = 0, video_id = 11;
+ char * temp2;
+ char *device_str[4] = {"/dev/video11", "/dev/video23", "/dev/video35", "/dev/video47"};
+
+ char mode_temp = 's';
+ char *param_temp;
+
+
+ if(argc < 5 || (tolower(*(argv[1])) != 'd') )
+ {
+ print_usage();
+ return -EINVAL;
+ }
+
+ sscanf(argv[2], "%d", &device_id );
+ i += 2;
+
+ if( device_id <= 0 || device_id > 4 )
+ {
+ print_usage();
+ return -EINVAL;
+ }
+
+ printf("\n********************************* \n");
+
+ if((fp = open(device_str[device_id-1], O_RDWR)) == -1)
+ {
+ printf("Error: cannot open device file %s !\n", device_str[device_id-1]);
+ return -EINVAL;
+ }
+
+ printf("Device %s open for IOCTL successfully!\n", device_str[device_id-1]);
+
+
+ for( ; i < argc; i++)
+ {
+ temp2 = argv[i];
+ mode_temp = tolower(temp2[0]);
+ param_temp = argv[i+1];
+
+
+ switch(mode_temp)
+ {
+ case 'r':
+ {
+ downstream_user_struct arguments;
+
+ sscanf(param_temp, "%x", &register_addr );
+
+ arguments.reg_address = register_addr;
+ arguments.command = REG_READ;
+
+ printf("Read parameters: read register = 0x%x, command = %d \n", arguments.reg_address, arguments.command);
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ printf("Reg 0x%x = 0x%x\n", arguments.reg_address, arguments.reg_data);
+ }
+ break;
+
+ case 'w':
+ {
+ downstream_user_struct arguments;
+
+ sscanf(param_temp, "%x", &register_addr );
+ sscanf(argv[i+2], "%x", &write_value );
+ i++;
+
+ arguments.command = REG_WRITE;
+ arguments.reg_address = register_addr;
+ arguments.reg_data = write_value;
+
+ printf("Write parameters: write register = 0x%x, write_value = 0x%x, command = %d \n", arguments.reg_address, arguments.reg_data, arguments.command);
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ }
+ break;
+
+ default:
+ printf("Please verify the options are correct!\n");
+ break;
+ }
+
+ i++;
+ }
+
+
+ printf("********************************* \n\n");
+ close(fp);
+ return 0;
+}
+
diff --git a/v4l2-apps/util/cx25821/setAlsaVolume b/v4l2-apps/util/cx25821/setAlsaVolume
new file mode 100644
index 000000000..55dd3dc89
--- /dev/null
+++ b/v4l2-apps/util/cx25821/setAlsaVolume
@@ -0,0 +1,2 @@
+amixer set Master,0 100% unmute
+amixer set Capture,0 90% captur
diff --git a/v4l2-apps/util/cx25821/setvideosetting.c b/v4l2-apps/util/cx25821/setvideosetting.c
new file mode 100644
index 000000000..87e36045d
--- /dev/null
+++ b/v4l2-apps/util/cx25821/setvideosetting.c
@@ -0,0 +1,187 @@
+/*
+ * Driver for the Conexant CX25821 PCIe bridge
+ *
+ * Copyright (C) 2009 Conexant Systems Inc.
+ * Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <linux/errno.h>
+#include <linux/ioctl.h>
+
+
+#define SET_VIDEO_STD 800
+#define SET_PIXEL_FORMAT 1000
+#define ENABLE_CIF_RESOLUTION 1001
+
+
+#define PIXEL_FRMT_422 4
+#define PIXEL_FRMT_411 5
+#define PIXEL_FRMT_Y8 6
+#define ALL_DECODERS 752
+
+typedef struct {
+ char *vid_stdname;
+ int pixel_format;
+ int cif_resolution_enable;
+ int cif_width;
+ int decoder_select;
+ int command;
+} downstream_user_struct;
+
+
+void print_usage()
+{
+ printf("\n*********************************\n");
+ printf("Sample Usage: ./set d 1 standard NTSC format 422 7 resolution 320 7\n");
+ printf(" device_id Device ID (1 and above) for MultiCard\n");
+ printf(" standard Video Standard (PAL/NTSC)\n");
+ printf(" format Output Pixel Format (422 or 411) for specific decoder (e.g. 7)\n");
+ printf(" resolution 352/320 for CIF and 720 for D1 resolution for specific decoder (e.g. 7)\n");
+}
+
+int main(int argc, char** argv)
+{
+ unsigned int cmd= 0 ;
+ int fp;
+ int i = 1, j = 0, k = 0, len = 0;
+ int mode = 0;
+ int pixel_format = 0;
+ int width_input = 0;
+ int decoder_input = 0;
+ int device_id = 0, video_id = 11;
+ char * temp2;
+ char *device_str[4] = {"/dev/video11", "/dev/video23", "/dev/video35", "/dev/video47"};
+
+ char mode_temp = 's';
+ char *param_temp;
+
+
+ if(argc < 3 || (tolower(*(argv[1])) != 'd') )
+ {
+ print_usage();
+ return -EINVAL;
+ }
+
+ sscanf(argv[2], "%d", &device_id );
+ i += 2;
+
+ if( device_id <= 0 || device_id > 4 )
+ {
+ print_usage();
+ return -EINVAL;
+ }
+
+ printf("\n********************************* \n");
+
+ if((fp = open(device_str[device_id-1], O_RDWR)) == -1)
+ {
+ printf("Error: cannot open device file %s !\n", device_str[device_id-1]);
+ return -EINVAL;
+ }
+
+ printf("Device %s open for IOCTL successfully!\n", device_str[device_id-1]);
+
+
+ for( ; i < argc; i++)
+ {
+ temp2 = argv[i];
+ mode_temp = tolower(temp2[0]);
+ param_temp = argv[i+1];
+
+
+ switch(mode_temp)
+ {
+ case 's':
+ {
+ downstream_user_struct arguments;
+ char * temp = param_temp;
+ arguments.vid_stdname = (tolower(temp[0]) == 'p') ? "PAL" : "NTSC";
+ arguments.command = SET_VIDEO_STD;
+
+ printf("User parameters: vid_stdname = %s, command = %d \n", arguments.vid_stdname, arguments.command);
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ }
+ break;
+
+ case 'f':
+ {
+ sscanf(param_temp, "%d", &pixel_format );
+ sscanf(argv[i+2], "%d", &decoder_input ); i++;
+
+ if( pixel_format < 411 || pixel_format > 422)
+ pixel_format = 422;
+
+ if( decoder_input < 0 )
+ decoder_input = ALL_DECODERS;
+
+ downstream_user_struct arguments;
+ arguments.pixel_format = (pixel_format == 411) ? PIXEL_FRMT_411 : PIXEL_FRMT_422;
+ arguments.decoder_select = decoder_input;
+ arguments.command = SET_PIXEL_FORMAT;
+
+ printf("User parameters: pixel_format = %d, decoder_input = %d, command = %d \n", arguments.pixel_format, arguments.decoder_select, arguments.command);
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ }
+ break;
+
+ case 'r':
+ {
+ sscanf(param_temp, "%d", &width_input );
+ sscanf(argv[i+2], "%d", &decoder_input ); i++;
+
+ if( width_input < 320 || width_input > 352 )
+ width_input = 720;
+
+ if( decoder_input < 0 )
+ decoder_input = ALL_DECODERS;
+
+ downstream_user_struct arguments;
+ arguments.cif_resolution_enable = (width_input == 320 || width_input == 352) ? 1 : 0;
+ arguments.cif_width = width_input;
+ arguments.decoder_select = decoder_input;
+ arguments.command = ENABLE_CIF_RESOLUTION;
+
+ printf("User parameters: cif_resolution_enable = %d, decoder_input = %d, command = %d \n", arguments.cif_resolution_enable, arguments.decoder_select, arguments.command);
+
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ }
+ break;
+
+ default:
+ printf("Please verify the options are correct!\n");
+ break;
+ }
+
+ i++;
+ }
+
+
+ printf("********************************* \n\n");
+ close(fp);
+ return 0;
+}
diff --git a/v4l2-apps/util/cx25821/upstream_app.c b/v4l2-apps/util/cx25821/upstream_app.c
new file mode 100644
index 000000000..97f7b84aa
--- /dev/null
+++ b/v4l2-apps/util/cx25821/upstream_app.c
@@ -0,0 +1,221 @@
+/*
+ * Driver for the Conexant CX25821 PCIe bridge
+ *
+ * Copyright (C) 2009 Conexant Systems Inc.
+ * Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <linux/errno.h>
+#include <linux/ioctl.h>
+
+#define VID_UPSTREAM_SRAM_CHANNEL_I 9
+#define VID_UPSTREAM_SRAM_CHANNEL_J 10
+#define AUDIO_UPSTREAM_SRAM_CHANNEL_B 11
+#define PIXEL_FRMT_422 4
+#define PIXEL_FRMT_411 5
+#define UPSTREAM_START_VIDEO 700
+#define UPSTREAM_STOP_VIDEO 701
+#define UPSTREAM_START_AUDIO 702
+#define UPSTREAM_STOP_AUDIO 703
+#define UPSTREAM_DUMP_REGISTERS 702
+
+
+typedef struct {
+ char *input_filename;
+ char *vid_stdname;
+ int pixel_format;
+ int channel_select;
+ int command;
+} upstream_user_struct;
+
+void print_video_usage()
+{
+ printf("\n************************************************************************ \n");
+ printf("Video Sample Usage: ./upstream_app d 1 v /root/filename.yuv NTSC 422 1 start \n");
+ printf("Argument 0: ./upstream_app \n");
+ printf("Argument 1: Device ID (1 and above)\n");
+ printf("Argument 2: v for video\n");
+ printf("Argument 3: input file name \n");
+ printf("Argument 4: Video Standard \n");
+ printf("Argument 5: Pixel Format (Y422 or Y411) \n");
+ printf("Argument 6: Upstream Channel Number\n");
+ printf("Argument 7: start/stop command\n\n");
+}
+
+void print_audio_usage()
+{
+ printf("\n************************************************************************ \n");
+ printf("Audio Sample Usage: ./upstream_app d 1 a /root/audio.wav start\n");
+ printf("Argument 0: ./upstream_app \n");
+ printf("Argument 1: Device ID (1 and above)\n");
+ printf("Argument 2: a for audio \n");
+ printf("Argument 3: input file name \n");
+ printf("Argument 4: start/stop command\n\n");
+}
+
+int main(int argc, char** argv)
+{
+ int fp;
+ unsigned int cmd= 0 ;
+ int i = 1;
+ int mode = 0;
+ int pixel_format = 422;
+ int channel_select = 1;
+ int device_id = 0, video_id = 11;
+ char * temp2;
+ char *video_device_str[4][2] = {{"/dev/video8", "/dev/video9"}, {"/dev/video20", "/dev/video21"},
+ {"/dev/video32", "/dev/video33"}, {"/dev/video44", "/dev/video45"} };
+ char *audio_device_str[4] = {"/dev/video10", "/dev/video22", "/dev/video34", "/dev/video46"};
+ char mode_temp = 'v';
+
+ if(argc < 2 || (tolower(*(argv[1])) != 'd') )
+ {
+ print_video_usage();
+ print_audio_usage();
+ return -EINVAL;
+ }
+ else
+ {
+ sscanf(argv[2], "%d", &device_id );
+ i += 2;
+
+ if( device_id <= 0 || device_id > 4 )
+ {
+ print_video_usage();
+ print_audio_usage();
+ return -EINVAL;
+ }
+
+ temp2 = argv[i];
+ mode_temp = tolower(temp2[0]);
+ switch(mode_temp)
+ {
+ case 'v':
+ if( argc < 9 )
+ {
+ print_video_usage();
+ return -EINVAL;
+ }
+ break;
+
+ case 'a':
+ if( argc < 6 )
+ {
+ print_audio_usage();
+ return -EINVAL;
+ }
+ break;
+ }
+ }
+
+ if( mode_temp == 'v' || mode_temp == 'a' )
+ {
+ FILE* file_ptr = fopen(argv[4], "r");
+
+ if( !file_ptr )
+ {
+ printf("\nERROR: %s file does NOT exist!!! \n\n", argv[4]);
+ return -EINVAL;
+ }
+
+ fclose(file_ptr);
+ }
+ else
+ {
+ print_video_usage();
+ print_audio_usage();
+ return -EINVAL;
+ }
+
+ printf("\n*************************************************************** \n");
+
+ switch(mode_temp)
+ {
+ case 'v':
+ {
+ char * temp = argv[5];
+ upstream_user_struct arguments;
+ arguments.input_filename = argv[4];
+ arguments.vid_stdname = (tolower(temp[0]) == 'p') ? "PAL" : "NTSC";
+ sscanf(argv[6], "%d", &pixel_format);
+ sscanf(argv[7], "%d", &channel_select);
+ arguments.pixel_format = (pixel_format == 422) ? PIXEL_FRMT_422 : PIXEL_FRMT_411;
+ arguments.channel_select = (channel_select==1) ? VID_UPSTREAM_SRAM_CHANNEL_I : VID_UPSTREAM_SRAM_CHANNEL_J;
+ temp = argv[8];
+ arguments.command = (strcasecmp("STOP", temp) == 0) ? UPSTREAM_STOP_VIDEO : UPSTREAM_START_VIDEO;
+
+
+ if( channel_select >= 1 && channel_select <= 2 )
+ {
+ if((fp = open(video_device_str[device_id-1][channel_select-1], O_RDWR)) == -1)
+ {
+ printf("Error: cannot open device file %s !\n", video_device_str[device_id-1][channel_select-1]);
+ return -EINVAL;
+ }
+
+ printf("Device %s open for IOCTL successfully!\n", video_device_str[device_id-1][channel_select-1]);
+ printf("UPSTREAM parameters: filename = %s, channel_select(I=1) = %d \n", arguments.input_filename, channel_select);
+
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ {
+ printf("Error: ioctl FAILED!\n");
+ }
+ }
+ }
+ break;
+
+ case 'a':
+ {
+ char * temp = argv[5];
+ upstream_user_struct arguments;
+ arguments.input_filename = argv[4];
+ arguments.vid_stdname = "NTSC";
+ arguments.pixel_format = PIXEL_FRMT_422;
+ arguments.channel_select = AUDIO_UPSTREAM_SRAM_CHANNEL_B;
+ arguments.command = (strcasecmp("STOP", temp) == 0) ? UPSTREAM_STOP_AUDIO : UPSTREAM_START_AUDIO;
+
+
+ if((fp = open(audio_device_str[device_id-1], O_RDWR)) == -1)
+ {
+ printf("Error: cannot open device file %s !\n", audio_device_str[device_id-1]);
+ return -EINVAL;
+ }
+
+ printf("Device %s open for IOCTL successfully!\n", audio_device_str[device_id-1]);
+ printf("UPSTREAM parameters: filename = %s, audio channel = %d \n", arguments.input_filename, arguments.channel_select);
+
+
+ if((ioctl(fp, arguments.command, (char *) &arguments)) == -1)
+ printf("Error: ioctl FAILED!\n");
+ }
+ break;
+
+ default:
+ printf("ERROR: INVALID ioctl command!\n");
+ return -EINVAL;
+ }
+
+ printf("*************************************************************** \n\n");
+ close(fp);
+ return 0;
+}