Date: Wed, 2 Mar 2005 12:02:38 GMT From: Luis López Solé <cronopiolopez@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/78293: Proposition for the review of multimedia/pvr250 Message-ID: <200503021202.j22C2cjY008692@www.freebsd.org> Resent-Message-ID: <200503021210.j22CALo9059651@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 78293 >Category: ports >Synopsis: Proposition for the review of multimedia/pvr250 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Wed Mar 02 12:10:20 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Luis López Solé >Release: 5.3 STABLE >Organization: n/a >Environment: FreeBSD workstation.documentanix.org 5.3-STABLE FreeBSD 5.3-STABLE #0: Thu Feb 10 11:13:57 CET 2005 luis@workstation.documentanix.org:/usr/obj/usr/src/sys/CXM2 i386 >Description: This revision provides with 5 new ioctl's: CODEC_ASSIGN_ST (for switch between multiple profile), CODEC_ASSIGN_ASR (change aspect ratio of current load profile), CODEC_ASSIGN_BITRATES (change bitrate params of current load profile), CODEC_ASSIGN_AUDIO_PROP (allows switch between 6 audio types) and CODEC_USER_GPROP (read current load profile). NOTE: Only tested on this. >How-To-Repeat: For test this revision follow next steps: 1. #cd /usr/ports/multimedia/pvr250 ; make extract 2. #cd work ; sh sharfile (see fix the problem if known for shar file) 3. #make pre-build ; make ; make install-dist or if you want install compiled examples : #make pre-build ; make ; make install-dist ; make install-dist-examples 4. Now you need #cd .. and recompile the port with: #make and them: #cp work/modules/cxm/cxm/*.ko work/modules/cxm/cxm_iic/*.ko /boot/kernel/ 5. And last. Unload cxm old modules (if is necessary), load new modules and test NOTE: If this revision is accepted have doc for this (some README's and manpage). >Fix: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # . # ./src # ./src/ioctl_codec_commands.c # ./src/out_msg.c # ./src/help.c # ./src/main.c # ./src/codec_conf_interactive.c # ./src/Makefile # ./examples # ./examples/view-profile.c # ./examples/setprofile.c # ./examples/setbitrate.c # ./examples/setaudio.c # ./examples/setaspect.c # ./examples/Makefile # ./patch_cxm_h # ./Makefile # ./patch_cxm_c # ./ioctl_codec.h # ./patch_modules_cxm_cxm_Makefile # echo c - . mkdir -p . > /dev/null 2>&1 echo c - ./src mkdir -p ./src > /dev/null 2>&1 echo x - ./src/ioctl_codec_commands.c sed 's/^X//' >./src/ioctl_codec_commands.c << 'END-of-./src/ioctl_codec_commands.c' X/* X * Copyright (c) 2005 X * Luis López Solé <cronopilopez@gmail.com>. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Luis López Solé. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE X * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, X * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN X * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X * X * NOTE: This project had not been realized without John Wehle's previous X * work and the documenattion of ivtv project. X */ X /* X * Ioctl commands module for pvr250-codecconf. X */ X#include <stdio.h> X#include <stdlib.h> X#include <fcntl.h> X#include <sys/ioctl.h> X#include "../dev/cxm/ioctl_codec.h" X Xvoid codec_view_profile () X{ X X int cfd; X X struct cxm_user_ioctl_codec *codec; X X codec = (struct cxm_user_ioctl_codec *)calloc(sizeof(struct cxm_user_ioctl_codec),1); X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "---open() of /dev/cxm0 failed.---" ); X exit(1); X } X X if ( ioctl( cfd, CODEC_USER_GPROP, codec ) < 0 ) { X perror( "---ioctl( cfd, CODEC_USER_GPROP ) failed.---" ); X close ( cfd ); X exit (1); X } X X printf("=======================================================================\n"); X printf("#################--CURRENT-LOAD-PROFILE-&-SETTINGS--###################\n"); X printf("=======================================================================\n"); X if ( codec->stream_type == 10 ){ X printf("|#| 1) Steam Profile Type: DVD \n"); X } X else if( codec->stream_type == 12 ){ X printf("|#| 1) Steam Profile Type: SVCD\n"); X } X else if( codec->stream_type == 11){ X printf("|#| 1) Steam Type: VCD\n"); X } X else if( codec->stream_type == 0 ){ X printf("|#| 1) Steam Profile Type: MPEG2\n"); X } X else if( codec->stream_type == 2 ){ X printf("|#| 1) Steam Profile Type: MPEG1\n"); X } X else if( codec->stream_type == 13 ){ X printf("|#| 1) Steam Profile Type: DVDS1\n"); X } X else if( codec->stream_type == 14 ){ X printf("|#| 1) Steam Profile Type: DVDS2 \n"); X } X else if( codec->stream_type == 1 ){ X printf("|#| 1) Steam Profile Type: MPEG2_TS \n"); X } X printf("|#| 2) fps: %d\n", codec->fps ); X printf("|#| 3) Width: %d \n",codec->width ); X printf("|#| 4) Height: %d\n",codec->height ); X printf("|#| 5) Suorce height: %d\n",codec->source_height ); X printf("|#| 6) Aspect: %d \n",codec->aspect ); X printf("|#| 7) Pulldown: %d\n", codec->pulldown ); X printf("|#| 8) Bitrate properties:\n"); X printf("|#| - Bitrate mode: %d (0 for VBR, 1 for CBR)\n",codec->bitrate.mode ); X printf("|#| - Bitrate average: %d Kb/s\n",codec->bitrate.average / 1000 ); X printf("|#| - Bitrate peak: %d Kb/s\n",codec->bitrate.peak / 1000 ); X if (codec->audio == 0xe9){ X printf("|#| 9) Audio type: 384 kb/s, 48 Khz, Layer II.\n"); X } X else if (codec->audio == 0xb9){ X printf("|#| 9) Audio type: 224 kb/s, 48 Khz, Layer II.\n"); X } X else if (codec->audio == 0xa9){ X printf("|#| 9) Audio type: 192 kb/s, 48 Khz, Layer II.\n"); X } X else if (codec->audio == 0xe8){ X printf("|#| 9) Audio type: 384 kb/s, 44.1 Khz, Layer II.\n"); X } X else if (codec->audio == 0xb8){ X printf("|#| 9) Audio type: 224 kb/s, 44.1 Khz, Layer II.\n"); X } X else if (codec->audio == 0xa8){ X printf("|#| 9) Audio type: 192 kb/s, 44.1 Khz, Layer II.\n"); X } X printf("|#| 10) GOP Properties: closure=%d, frames=%d, bframes=%d\n",\ X codec->gop.closure, codec->gop.frames, codec->gop.bframes ); X printf("|#| 11) DNR Properties: mode=%d, type=%d, spatial=%d, temporal=%d \n",\ X codec->dnr.mode, codec->dnr.type, codec->dnr.spatial, codec->dnr.temporal); X printf("|#| 12) VBI info: %d start, %d nlines, %d cc \n",\ X codec->vbi.start, codec->vbi.nlines, codec->vbi.cc ); X printf("=======================================================================\n"); X printf("=======================================================================\n"); X close ( cfd ); X} X Xvoid codec_setprofile ( unsigned int stdtv, unsigned long stream_type ) X{ X int cfd; X struct assign_st *user_st; X X user_st = (struct assign_st *)calloc(sizeof(struct assign_st),1); X X user_st->stdtv = stdtv; X user_st->stream_type = stream_type; X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "---open() of /dev/cxm0 failed.---" ); X } X X if ( ioctl( cfd, CODEC_ASSIGN_ST, user_st ) < 0 ) { X perror( "---ioctl( cfd, CODEC_ASSIGN_ST ) failed.---" ); X close ( cfd ); X } X close ( cfd ); X} X Xvoid codec_setaspect(unsigned int aspect) X{ X int cfd; X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "---open() of /dev/cxm0 failed.---" ); X } X X if ( ioctl( cfd, CODEC_ASSIGN_ASR, &aspect ) < 0 ) { X perror( "---ioctl( cfd, CODEC_ASSIGN_ASR ) failed.---" ); X close ( cfd ); X } X close ( cfd ); X} X Xvoid codec_setbitrate (unsigned short mode, unsigned int average, unsigned int peak) X{ X X int cfd; X struct codec_bitrate *user_bitrate; X X user_bitrate=(struct codec_bitrate *)calloc(sizeof(struct codec_bitrate),1); X X user_bitrate->mode = mode; X user_bitrate->average = average; X user_bitrate->peak = peak; X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "---open() of /dev/cxm0 failed.---" ); X } X X if ( ioctl( cfd, CODEC_ASSIGN_BITRATES, user_bitrate ) < 0 ) { X perror( "---ioctl( cfd, CODEC_ASSIGN_BITRATES ) failed.---" ); X close (cfd); X } X close ( cfd ); X} Xvoid codec_setaudio (int audio){ X X int cfd; X int audio_type; X X switch (audio){ X case 1: X audio_type = CODEC_AUDIO_L2_48_384; X audio_01(); X break; X X case 2: X audio_type = CODEC_AUDIO_L2_48_224; X audio_02(); X break; X X case 3: X audio_type = CODEC_AUDIO_L2_48_192; X audio_03(); X break; X X case 4: X audio_type = CODEC_AUDIO_L2_441_384; X audio_04(); X break; X X case 5: X audio_type = CODEC_AUDIO_L2_441_224; X audio_05(); X break; X X case 6: X audio_type = CODEC_AUDIO_L2_441_192; X audio_06(); X break; X X default: X audio_error_msg(); X break; X } X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "---open() of /dev/cxm0 failed.---" ); X exit(1); X } X X if ( ioctl( cfd, CODEC_ASSIGN_AUDIO_PROP, &audio_type ) < 0 ) { X perror( "---ioctl( tfd, CODEC_ASSIGN_AUDIO_PROP ) failed.---" ); X close ( cfd ); X } X close ( cfd ); X} END-of-./src/ioctl_codec_commands.c echo x - ./src/out_msg.c sed 's/^X//' >./src/out_msg.c << 'END-of-./src/out_msg.c' X/* X * Copyright (c) 2005 X * Luis López Solé <cronopilopez@gmail.com>. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Luis López Solé. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE X * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, X * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN X * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X * X * NOTE: This project had not been realized without John Wehle's previous X * work and the documenattion of ivtv project. X */ X /* X * Out msg. for pvr250-codecconf. X */ X#include <stdio.h> X X/* Misc. msg. */ Xvoid bad_param(){ X printf("-------------------\n"); X printf("---Unknow params---\n"); X printf("-------------------\n"); X} X Xvoid default_opt(){ X printf("-----------------------------------------------------------\n"); X printf("---UNKNOW VALUE. Taking the default option [default no].---\n"); X printf("-----------------------------------------------------------\n"); X} X X/* Profile msg. */ Xvoid ask_profile(){ X printf("|#| Select profile? (y/n):"); X} X Xvoid profile_skip(){ X printf ("Profile select conf skiped...\n"); X} X Xvoid profile_type_msg(){ X printf("|#| Select your profile: "); X} X Xvoid profile_dvd(){ X printf( "Setting to DVD stream type\n"); X} X Xvoid profile_svcd(){ X printf( "Setting to SVCD stream type\n"); X} X Xvoid profile_vcd(){ X printf( "Setting to VCD stream type\n"); X} X Xvoid profile_mpeg2(){ X printf( "Setting to MPEG2 stream type\n"); X} X Xvoid profile_mpeg1(){ X printf( "Setting to MPEG1 stream type\n"); X} X Xvoid profile_dvds1(){ X printf( "Setting to DVDS1 stream type\n"); X} X Xvoid profile_dvds2(){ X printf( "Setting to DVDS2 stream type\n"); X} X Xvoid profile_mpeg2_ts(){ X printf( "Setting to MPEG2_TS stream type\n"); X} X Xvoid profile_error_type_msg(){ X printf("---------------------------------------------------\n"); X printf("--------Unknow profile, supported profiles:--------\n" X "---DVD|SVCD|VCD|MPEG2|MPEG1|DVDS1|DVDS2|MPEG2_TS---\n"); X printf("---------------------------------------------------\n"); X} X Xvoid profile_stdtv_msg(){ X printf("|#| Put fps for select between NTSC or PAL/SECAM\n" X "|#| 30 for NTSC, 25 for PAL/SECAM: "); X} X Xvoid profile_pal(){ X printf("PAL/SECAM standard select\n"); X} X Xvoid profile_ntsc(){ X printf ("NTSC standard select\n") ; X} X Xvoid profile_error_stdtv_msg(){ X printf("-------------------------------------------------------\n"); X printf("---Incorrect selection, 30 for NTSC 25 for PAL/SECAM---\n"); X printf("-------------------------------------------------------\n"); X} X X/* Aspect msg. */ Xvoid ask_aspect(){ X printf("|#| Configure aspect params? (y/n):"); X} X Xvoid aspect_skip(){ X printf ("Aspect conf skiped...\n"); X} X Xvoid aspect_select_msg(){ X printf("|#| Select aspect: "); X} X Xvoid aspect_forbbiden(){ X printf("Setting to aspect: 0:0\n"); X} X Xvoid aspect_square(){ X printf("Setting to aspect: 1:1\n"); X} X Xvoid aspect_4_3(){ X printf("Setting to aspect: 4:3\n"); X} X Xvoid aspect_16_9(){ X printf("Setting to aspect: 16:9\n"); X} X Xvoid aspect_221_1(){ X printf("Setting to aspect: 2.21:1\n"); X} Xvoid aspect_error_msg(){ X printf("-------------------------------------\n"); X printf("---Aspect don't set. Unknow aspect---\n"); X printf("-------------------------------------\n"); X} X X/* Bitrate msg. */ Xvoid ask_bitrate(){ X printf("|#| Configure bitrate params? (y/n):"); X} X Xvoid bitrate_skip(){ X printf ("Bitrate conf skiped...\n"); X} X Xvoid bitrate_select_mode(){ X printf("|#| Select mode 0 for VBR, 1 for CBR: "); X} X Xvoid bitrate_select_average(){ X printf("|#| Put average in kb/s: "); X} X Xvoid bitrate_select_peak(){ X printf("|#| Put peak in kb/s (remember, if mode is 1 peak must be 0): "); X} X Xvoid bitrate_error_mode_msg(){ X printf("------------------------------------------\n"); X printf("---Bitrate don't set. Unsupported mode.---\n"); X printf("------------------------------------------\n"); X} X Xvoid bitrate_error_peak_msg(){ X printf("--------------------------------------------------------------\n"); X printf("---Bitrate don't set. Remember: If mode = 1 peak must be 0.---\n"); X printf("--------------------------------------------------------------\n"); X} X Xvoid bitrate_set_msg(unsigned short mode, unsigned int average, unsigned int peak){ X printf("Setting to %d mode, %d average, %d bitrate.\n", mode, average, peak); X} X X/* Audio msg. */ Xvoid ask_audio(){ X printf("|#| Select your audio type? (y/n):"); X} X Xvoid audio_skip(){ X printf ("Audio types conf skiped...\n"); X} X Xvoid audio_select_msg (){ X printf("|#| Select audio bitrate mode [1-6]:"); X} X Xvoid audio_error_msg(){ X printf("-------------------------------------------------\n"); X printf("---Audio don't set. Unknow Audio bitrate mode.---\n"); X printf("-------------------------------------------------\n"); X} X Xvoid audio_01(){ X printf("Setting audio to 384 kb/s, 48 Khz, Layer II.\n"); X} X Xvoid audio_02(){ X printf("Setting audio to 224 kb/s, 48 Khz, Layer II.\n"); X} X Xvoid audio_03(){ X printf("Setting audio to 192 kb/s, 48 Khz, Layer II.\n"); X} X Xvoid audio_04(){ X printf("Setting audio to 384 kb/s, 44.1 Khz, Layer II.\n"); X} X Xvoid audio_05(){ X printf("Setting audio to 224 kb/s, 44.1 Khz, Layer II.\n"); X} X Xvoid audio_06(){ X printf("Setting audio to 192 kb/s, 44.1 Khz, Layer II.\n"); X} END-of-./src/out_msg.c echo x - ./src/help.c sed 's/^X//' >./src/help.c << 'END-of-./src/help.c' X/* X * Copyright (c) 2005 X * Luis López Solé <cronopilopez@gmail.com>. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed Luis López Solé. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE X * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, X * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN X * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X * X * NOTE: This project had not been realized without John Wehle's previous X * work and the documenattion of ivtv project. X */ X /* X * Help msg. for pvr250-codecconf. X */ X#include <stdio.h> X Xvoid main_help(){ X printf("=======================================================================\n"); X printf("######################--MAIN-HELP--####################################\n"); X printf("=======================================================================\n"); X printf("|#| Usage: pvr250-codecconf < -i| -q |-h |-h helptype |-p profile fps \n"); X printf("|#| | -b mode average bitrate | -a aspect | -s audiotype > \n"); X printf("|#| \n"); X printf( "|#| -i Enable interactive mode. In interactive mode, the application\n" X "|#| guide stepwise showing helps to user and consulting parameter\n" X "|#| to parameter. \n" X "|#| -q The same that previous but without showing helps. \n" X "|#| -h Show this. \n" X "|#| -h <helptype> Where helptype can take the following values:. \n" X "|#| < setprofile | setaspect | setbitrate | setaudio >\n" X "|#| Example: pvr250-codecconf -h setprofile shows help\n" X "|#| to select your profile. \n" X "|#| -v Show current load profile and exit. \n" X "|#| \n" X "|#| BATCH MODES \n" X "|#| \n" X "|#| -p <profiletype> <fps> (show -h setprofile for more details).\n" X "|#| -b <mode> <average> <peak> (show -h setbitrate for more details).\n" X "|#| -a <aspect> (show -h setaspect for more details). \n" X "|#| -s <audio> (show -h setaudio for more details). \n"); X printf("=======================================================================\n"); X printf("=======================================================================\n"); X X} X Xvoid help_setprofile () X{ X printf("=======================================================================\n"); X printf("###################--PROFILE-SELECT-CONF--#############################\n"); X printf("=======================================================================\n"); X printf("|#| Usage: setprofile <profile> <mode> \n"); X printf("|#| or pvr250-codecconf -p <profile> <mode> in batch mode. \n"); X printf("|#| Profiles: < DVD|SVCD|VCD|MPEG2|MPEG1|DVDS1|DVDS2|MPEG2_TS > \n"); X printf("|#| Modes: < 30 | 25 > 30 for NTSC profiles or 25 for PAL/SECAM \n"); X printf( "|#| DVD Enable DVD profile. Video: 720x575/480, 9520 kbs.\n" X "|#| Audio: 384 kbs 48 Khz \n" X "|#| SVCD Enable SVCD profile. Video: 480x480/576, 2500 kbs.\n" X "|#| Audio: 224 kbs 41.1 Khz\n" X "|#| VCD Enable VCD profile. Video: 352x240/288, 1150 kbs.\n" X "|#| Audio 224 kbs 41.1 Khz.\n" X "|#| MPEG2 Enable MPEG2 profile. Video: 720x576/480, 8192 kbs.\n" X "|#| Audio: 384 kbs 48 Khz.\n" X "|#| MPEG1 Enable MPEG1 profile. Video: 352x240/288, 1823 kbs.\n" X "|#| Audio: 224 kbs 44.1 Khz.\n" X "|#| DVDS1 Enable DVDS1 profile. Video: 720x576/480, 4096 kbs.\n" X "|#| Audio: 384 kbs 48 Khz.\n" X "|#| DVDS2 Enable DVDS2 profile. Video: 720x576/480, 2048 kbs.\n" X "|#| Audio: 224 kbs 48 Khz.\n" X "|#| MPEG2_TS Enable MPEG2_TS profile. Video: 720x576/480, 6144 kbs.\n" X "|#| Audio: 384 kbs 48 Khz. \n"); X printf("=======================================================================\n"); X printf("=======================================================================\n"); X} X Xvoid help_setaspect() X{ X printf("=======================================================================\n"); X printf("###############--ASPECT-RATIO-CONF--###################################\n"); X printf("=======================================================================\n"); X printf( X "|#| Usage setaspect: < 0:0 | 1:1 | 4:3 | 16:9 | 2.21:1 >\n" X "|#| or pvr250-codecconf -a <aspect> in batch mode. \n" X "|#| 0:0 forbidden mode. \n" X "|#| 1:1 square mode. \n" X "|#| 4:3 standard mode. \n" X "|#| 16:9 wide mode. \n" X "|#| 2.21:1 extend wide mode. \n"); X printf("=======================================================================\n"); X printf("=======================================================================\n"); X} X Xvoid help_setaudio() X{ X printf("=======================================================================\n"); X printf("################--AUDIO-TYPES-CONF--###################################\n"); X printf("=======================================================================\n"); X printf( X "|#| Usage setaudio: [1-6]\n" X "|#| or pvr250-codecconf -p <profile> <mode> in batch mode.\n" X "|#| 1 384 kb/s 48 Khz Layer 2 mode. \n" X "|#| 2 224 kb/s 48 Khz Layer 2 mode. \n" X "|#| 3 192 kb/s 48 Khz Layer 2 mode. \n" X "|#| 4 384 kb/s 44.1 Khz Layer 2 mode. \n" X "|#| 5 224 kb/s 44.1 Khz Layer 2 mode. \n" X "|#| 6 192 kb/s 44.1 Khz Layer 2 mode. \n"); X printf("=======================================================================\n"); X printf("=======================================================================\n"); X} X Xvoid help_setbitrate() X{ X printf("=======================================================================\n"); X printf("#################--BITRATE-PARAMS-CONF--###############################\n"); X printf("=======================================================================\n"); X printf( X "|#| Usage setbitrate: x y z (where x = mode, y = average and z = peak)\n" X "|#| or pvr250-codecconf -b <mode> <average> <peak> in batch mode.\n" X "|#| Exemple: \n" X "|#| Default DVD bitrate params: 0 9000 9520 \n" X "|#| First value is for mode: VBR 0, CBR 1. If the CBR is selected \n" X "|#| peak must be 0 \n" X "|#| NOTE: VBR is unsupported by MPEG1 and VCD profiles \n" X "|#| Average limits: Min 1150 kb/s Max 9520 kb/s\n"); X printf("=======================================================================\n"); X printf("=======================================================================\n"); X} END-of-./src/help.c echo x - ./src/main.c sed 's/^X//' >./src/main.c << 'END-of-./src/main.c' X/* X * Copyright (c) 2005 X * Luis López Solé <cronopilopez@gmail.com>. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Luis López Solé. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE X * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, X * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN X * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X * X * NOTE: This project had not been realized without John Wehle's previous X * work and the documenattion of ivtv project. X */ X /* X * Main module for pvr250-codecconf. X */ X#include <stdio.h> X#include <stdlib.h> X#include "../dev/cxm/ioctl_codec.h" X X#define EQ(str1, str2)(strcmp((str1), (str2)) == 0) X Xint main( int argc, char *argv[] ){ X X int qmode; X int audio; X unsigned short mode; X unsigned int stdtv; X unsigned int average; X unsigned int peak; X unsigned long stream_type; X unsigned int aspect; X X qmode = 0; X X if ( argc < 2 ) { X main_help (); X exit (1); X } X /* Interactive quiet mode */ X if ((argc == 2) && (EQ (argv[1], "-q"))){ X qmode = 1; X interactive_mode( qmode ); X } X /* Interactive mode */ X else if ((argc == 2) && (EQ (argv[1], "-i"))){ X interactive_mode( qmode ); X } X /* Help */ X else if ((argc == 2) && (EQ (argv[1], "-h"))){ X main_help (); X exit (1); X } X /* Show current load profile */ X else if ((argc == 2) && (EQ (argv[1], "-v"))){ X codec_view_profile(); X exit (1); X } X /* Help for select profile */ X else if ((argc == 3) && (EQ (argv[1], "-h")) && (EQ (argv[2], "setprofile"))){ X help_setprofile(); X exit(1); X } X /* Help for setting aspect */ X else if ((argc == 3) && (EQ (argv[1], "-h")) && (EQ (argv[2], "setaspect"))){ X help_setaspect(); X exit(1); X } X /* Help for setting bitrate */ X else if ((argc == 3) && (EQ (argv[1], "-h")) && (EQ (argv[2], "setbitrate"))){ X help_setbitrate(); X exit(1); X } X /* Help for select audio */ X else if ((argc == 3) && (EQ (argv[1], "-h")) && (EQ (argv[2], "setaudio"))){ X help_setaudio(); X exit(1); X } X /* START OF BATCH MODES*/ X /* Setting aspect */ X else if ((argc == 3) && (EQ (argv[1], "-a"))){ X if (EQ (argv[2], "0:0")){ X aspect = CODEC_ASR_FORBBIDEN; X aspect_forbbiden(); X codec_setaspect(aspect); X } X else if (EQ (argv[2], "1:1")){ X aspect = CODEC_ASR_SQUARE; X aspect_square(); X codec_setaspect(aspect); X } X else if (EQ (argv[2], "4:3")){ X aspect = CODEC_ASR_4_3; X aspect_4_3(); X codec_setaspect(aspect); X } X else if (EQ (argv[2], "16:9")){ X aspect = CODEC_ASR_16_9; X aspect_16_9(); X codec_setaspect(aspect); X } X else if (EQ (argv[2], "2.21:1")){ X aspect = CODEC_ASR_FORBBIDEN; X aspect_221_1(); X codec_setaspect(aspect); X } X else { X aspect_error_msg(); X help_setaspect (); X exit (1); X } X } X /* Select audio type */ X else if ((argc == 3) && (EQ (argv[1], "-s"))){ X audio = atoi(argv[2]); X if ( ( audio < 1 ) || ( audio > 6 ) ){ X audio_error_msg(); X help_setaudio(); X exit(1); X } X else { X codec_setaudio( audio ); X } X X } X /* Select profile */ X else if ((argc == 4) && (EQ (argv[1], "-p"))){ X /* Stream type. */ X if(EQ (argv[2], "DVD")){ X stream_type= CODEC_ST_DVD; X profile_dvd(); X } X else if(EQ (argv[2], "SVCD")){ X stream_type= CODEC_ST_SVCD; X profile_svcd(); X } X else if(EQ (argv[2], "VCD")){ X stream_type= CODEC_ST_VCD; X profile_vcd(); X } X else if(EQ (argv[2], "MPEG2")){ X stream_type= CODEC_ST_MPEG2_PROGRAM; X profile_mpeg2(); X } X else if(EQ (argv[2], "MPEG1")){ X stream_type= CODEC_ST_MPEG1; X profile_mpeg1(); X } X else if(EQ (argv[2], "DVDS1")){ X stream_type= CODEC_ST_DVD_S1; X profile_dvds1(); X } X else if(EQ (argv[2], "DVDS2")){ X stream_type= CODEC_ST_DVD_S2; X profile_dvds2(); X } X else if(EQ (argv[2], "MPEG2_TS")){ X stream_type= CODEC_ST_MPEG2_TS; X profile_mpeg2_ts(); X } X else{ X profile_error_type_msg(); X help_setprofile(); X exit (1); X } X /* NTSC or PAL/SECAM. */ X stdtv = atoi(argv[3]); X if ( stdtv == 30 ){ X profile_ntsc(); X } X else if( stdtv == 25 ){ X profile_pal(); X } X else{ X profile_error_stdtv_msg(); X help_setprofile(); X exit (1); X } X codec_setprofile(stdtv, stream_type); X } X else if ((argc == 5) && (EQ (argv[1], "-b"))){ X mode = atoi(argv[2]); X average = atoi(argv[3]); X peak = atoi(argv[4]); X if ((mode < 0) || (mode > 1)){ X bitrate_error_mode_msg(); X help_setbitrate(); X } X else if((mode == 1) && (peak != 0)){ X bitrate_error_peak_msg(); X help_setbitrate(); X } X else{ X codec_setbitrate(mode, average * 1000, peak * 1000 ); X bitrate_set_msg (mode, average, peak); X } X } X else{ X bad_param(); X main_help(); X exit(1); X } X X exit(0); X} END-of-./src/main.c echo x - ./src/codec_conf_interactive.c sed 's/^X//' >./src/codec_conf_interactive.c << 'END-of-./src/codec_conf_interactive.c' X/* X * Copyright (c) 2005 X * Luis López Solé <cronopilopez@gmail.com>. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Luis López Solé. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE X * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, X * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN X * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X * X * NOTE: This project had not been realized without John Wehle's previous X * work and the documenattion of ivtv project. X */ X /* X * Interactive module for pvr250-codecconf. X */ X#include <stdio.h> X#include "../dev/cxm/ioctl_codec.h" X X#define EQ(str1, str2)(strcmp((str1), (str2)) == 0) X Xvoid interactive_mode (int qmode){ X X char answer[1]; X char my_aspect[10]; X char my_stream_type[10]; X unsigned short mode; X int audio; X unsigned int aspect; X unsigned int average; X unsigned int peak; X unsigned int stdtv; X unsigned long stream_type; X X /* Select Profile*/ X if (qmode != 1){ X help_setprofile(); X } X X ask_profile(); X scanf("%s", &answer); X X if (EQ (answer, "n")){ X profile_skip(); X } X else if (EQ (answer, "y")){ X profile_type_msg(); X scanf("%s", &my_stream_type ); X if(EQ (my_stream_type, "DVD")){ X stream_type= CODEC_ST_DVD; X profile_dvd(); X } X else if(EQ (my_stream_type, "SVCD")){ X stream_type= CODEC_ST_SVCD; X profile_svcd(); X } X else if(EQ (my_stream_type, "VCD")){ X stream_type= CODEC_ST_VCD; X profile_vcd(); X } X else if(EQ (my_stream_type, "MPEG2")){ X stream_type= CODEC_ST_MPEG2_PROGRAM; X profile_mpeg2(); X } X else if(EQ (my_stream_type, "MPEG1")){ X stream_type= CODEC_ST_MPEG1; X profile_mpeg1(); X } X else if(EQ (my_stream_type, "DVDS1")){ X stream_type= CODEC_ST_DVD_S1; X profile_dvds1(); X } X X else if(EQ (my_stream_type, "DVDS2")){ X stream_type= CODEC_ST_DVD_S2; X profile_dvds2(); X } X else if(EQ ( my_stream_type, "MPEG2_TS")){ X stream_type = CODEC_ST_MPEG2_TS; X profile_mpeg2_ts(); X } X else { X profile_error_type_msg(); X exit(1); X } X profile_stdtv_msg(); X scanf("%u", &stdtv ); X if ( stdtv == 30 ){ X profile_ntsc(); X } X else if( stdtv == 25 ){ X profile_pal(); X } X else{ X profile_error_stdtv_msg(); X exit(1); X } X codec_setprofile( stdtv, stream_type ); X } X else{ X default_opt(); X } X X /* Set aspect */ X if (qmode != 1){ X help_setaspect(); X } X X ask_aspect(); X scanf("%s", &answer); X X if(EQ (answer, "n")){ X aspect_skip(); X } X else if(EQ (answer, "y")){ X aspect_select_msg(); X scanf("%s", &my_aspect); X X if(EQ (my_aspect, "0:0")){ X aspect = CODEC_ASR_FORBBIDEN; X aspect_forbbiden(); X codec_setaspect(aspect); X } X else if(EQ (my_aspect, "1:1")){ X aspect = CODEC_ASR_SQUARE; X aspect_square(); X codec_setaspect(aspect); X } X else if(EQ (my_aspect, "4:3")){ X aspect = CODEC_ASR_4_3; X aspect_4_3(); X codec_setaspect(aspect); X } X else if(EQ (my_aspect, "16:9")){ X aspect = CODEC_ASR_16_9; X aspect_16_9(); X codec_setaspect(aspect); X } X else if(EQ (my_aspect, "2.21:1")){ X aspect = CODEC_ASR_221_1; X aspect_221_1(); X codec_setaspect(aspect); X } X else X aspect_error_msg(); X } X else { X default_opt(); X } X X /* Set bitrate*/ X if (qmode != 1){ X help_setbitrate(); X } X ask_bitrate(); X scanf("%s", &answer); X X if (EQ (answer, "n")){ X bitrate_skip(); X } X else if (EQ (answer, "y")){ X bitrate_select_mode(); X scanf("%u", &mode ); X bitrate_select_average(); X scanf("%u", &average ); X bitrate_select_peak(); X scanf("%u", &peak ); X if ((mode < 0) || (mode > 1)){ X bitrate_error_mode_msg(); X } X else if((mode == 1) && (peak != 0)){ X bitrate_error_peak_msg(); X } X else{ X codec_setbitrate(mode, average * 1000, peak *1000); X bitrate_set_msg(mode, average, peak); X } X } X else{ X default_opt(); X } X X /* Set audio prop.*/ X if (qmode != 1){ X help_setaudio(); X } X X ask_audio(); X scanf("%s", &answer); X X X if (EQ (answer, "n")){ X audio_skip(); X } X else if (EQ (answer, "y")){ X audio_select_msg(); X scanf("%i", &audio ); X if ( ( audio < 1 ) || ( audio > 6 ) ){ X audio_error_msg(); X } X else { X codec_setaudio( audio ); X } X } X else{ X default_opt(); X } X X codec_view_profile (); X exit (0); X} END-of-./src/codec_conf_interactive.c echo x - ./src/Makefile sed 's/^X//' >./src/Makefile << 'END-of-./src/Makefile' Xall: main.o codec_conf_interactive.o ioctl_codec_commands.o help.o out_msg.o X cc main.o codec_conf_interactive.o ioctl_codec_commands.o help.o out_msg.o -o pvr250-codecconf END-of-./src/Makefile echo c - ./examples mkdir -p ./examples > /dev/null 2>&1 echo x - ./examples/view-profile.c sed 's/^X//' >./examples/view-profile.c << 'END-of-./examples/view-profile.c' X#include <stdio.h> X#include <fcntl.h> X#include <sys/ioctl.h> X#include <stdlib.h> X#include "../ioctl_codec.h" X X/****************************************************************************/ X/* viewprofile.c - Show current load profile of the cxm encoder card. */ X/* */ X/* COMPILE WITH: cc -o viewprofile viewprofile.c */ X/****************************************************************************/ X X Xint main() X{ X X int status; X int cfd; X X struct cxm_user_ioctl_codec *codec; X X codec = (struct cxm_user_ioctl_codec *)calloc(sizeof(struct cxm_user_ioctl_codec),1); X X status = 0; X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "open() of /dev/cxm0 failed." ); X exit(1); X } X X if ( ioctl( cfd, CODEC_USER_GPROP, codec ) < 0 ) { X perror( "ioctl( tfd, BT848_SCAPAREA ) failed." ); X status = 1; X close ( cfd ); X exit ( status ); X } X printf(" ###############################################################\n"); X if ( codec->stream_type == 10 ){ X printf(" # 1) Steam Profile Type: DVD \n"); X } X else if( codec->stream_type == 12 ){ X printf(" # 1) Steam Profile Type: SVCD\n"); X } X else if( codec->stream_type == 11){ X printf(" # 1) Steam Type: VCD\n"); X } X else if( codec->stream_type == 0 ){ X printf(" # 1) Steam Profile Type: MPEG2\n"); X } X else if( codec->stream_type == 2 ){ X printf(" # 1) Steam Profile Type: MPEG1\n"); X } X else if( codec->stream_type == 13 ){ X printf(" # 1) Steam Profile Type: DVDS1\n"); X } X else if( codec->stream_type == 14 ){ X printf(" # 1) Steam Profile Type: DVDS2 \n"); X } X else if( codec->stream_type == 1 ){ X printf(" # 1) Steam Profile Type: MPEG2_TS \n"); X } X printf(" # 2) fps: %d\n", codec->fps ); X printf(" # 3) Width: %d \n",codec->width ); X printf(" # 4) Height: %d\n",codec->height ); X printf(" # 5) Suorce height: %d\n",codec->source_height ); X printf(" # 6) Aspect: %d \n",codec->aspect ); X printf(" # 7) Pulldown: %d\n", codec->pulldown ); X printf(" # 8) Bitrate properties: \n" ); X printf(" # - Bitrate mode: %d (0 for VBR, 1 for CBR)\n",codec->bitrate.mode ); X printf(" # - Bitrate average: %d Kb/s\n",codec->bitrate.average / 1000 ); X printf(" # - Bitrate peak: %d Kb/s\n",codec->bitrate.peak / 1000 ); X printf(" # 9) Audio type: %d\n",codec->audio); X printf(" # 10) GOP Properties: closure=%d, frames=%d, bframes=%d\n",\ X codec->gop.closure, codec->gop.frames, codec->gop.bframes ); X printf(" # 11) DNR Properties: mode=%d, type=%d, spatial=%d, temporal=%d \n",\ X codec->dnr.mode, codec->dnr.type, codec->dnr.spatial, codec->dnr.temporal); X printf(" # 12) VBI info: %d start, %d nlines, %d cc \n",\ X codec->vbi.start, codec->vbi.nlines, codec->vbi.cc ); X printf(" ###############################################################\n\n"); X close ( cfd ); X exit ( status ); X} END-of-./examples/view-profile.c echo x - ./examples/setprofile.c sed 's/^X//' >./examples/setprofile.c << 'END-of-./examples/setprofile.c' X#include <stdio.h> X#include <fcntl.h> X#include <sys/ioctl.h> X#include <stdlib.h> X#include "../ioctl_codec.h" X X#define EQ(str1, str2)(strcmp((str1), (str2)) == 0) X/****************************************************************************/ X/* setprofile.c - Set the porfile of the cxm mpeg encoder card. */ X/* */ X/* COMPILE WITH: cc -o setprofile setprofile.c */ X/****************************************************************************/ X X Xstatic void Xusage() X{ X printf(" #######################################################################\n"); X printf(" Usage: setprofile < profile > < mode > \n"); X printf(" Profiles: < DVD |SVCD |VCD |MPEG2 |MPEG1 |DVDS1 |DVDS2 |MPEG2_TS >\n"); X printf(" Modes: < 30 | 25 > 30 for NTSC profiles or 25 for PAL/SECAM \n\n"); X printf( " DVD Enable DVD profile. Video: 720x575/480, 9520 kbs.\n" X " Audio: 384 kbs 48 Khz \n" X " SVCD Enable SVCD profile. Video: 480x480/576, 2500 kbs.\n" X " Audio: 224 kbs 41.1 Khz\n" X " VCD Enable VCD profile. Video: 352x288/352x240, 1150 kbs.\n" X " Audio 224 kbs 41.1 Khz.\n" X " MPEG2 Enable MPEG2 profile. Video: 720x576/480, 8192 kbs.\n" X " Audio: 384 kbs 48 Khz.\n" X " MPEG1 Enable MPEG1 profile. Video: 352x288/352x240, 2048 kbs.\n" X " Audio: 224 kbs 48 Khz.\n" X " DVDS1 Enable DVDS1 profile. Video: 720x576/480, 4096 kbs.\n" X " Audio: 384 kbs 48 Khz.\n" X " DVDS2 Enable DVDS2 profile. Video: 720x576/480, 2048 kbs.\n" X " Audio: 224 kbs 48 Khz.\n" X " MPEG2_TS Enable MPEG2_TS profile. Video: 720x576/480, 6144 kbs.\n" X " Audio: 384 kbs 48 Khz.\n"); X printf(" ######### 2^%#Xë select\n"); X } X else{ X printf ("Incorrect selection, 30 for NTSC 25 for PAL/SECAM\n"); X exit (1); X } X X if(EQ (argv[1], "DVD")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_DVD; X printf("Setting to %d stream type at %d fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "SVCD")){ X user_st=% select\n"); X } X else{ X printf ("Incorrect selection, 30 for NTSC 25 for PAL/SECAM\n"); X exit (1); X } X X if(EQ (argv[1], "DVD")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_DVD; X printf("Setting to %d stream type at %d fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "SVCD")){ X user_st=(struct assign_st *%2 2^%#Xë X else if(EQ (argv[1], "MPEG2")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_MPEG2_PROGRAM; X printf("Setting to %d stream type at d% fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "MPEG1")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->s X else if(EQ (argv[1], "MPEG2")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_MPEG2_PROGRAM; X printf("Setting to %d stream type at d% fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "MPEG1")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_MPEG1; X printf("Setting to %d stream type at %d fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "DVDS1")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_DVD_S1; X printf("Setting to %d stream type at %d fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "DVDS2")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_DVD_S2; X printf("Setting to %d stream type at %d fps \n",user_st->stream_type, user_st->stdtv); X } X X else if(EQ (argv[1], "MPEG2_TS")){ X user_st=(struct assign_st *)calloc(sizeof(struct assign_st),1); X user_st->stdtv = atoi(argv[2]); X user_st->stream_type= CODEC_ST_MPEG2_TS; X printf("Setting to %d stream type at %d fps \n",user_st->stream_type, user_st->stdtv); X } X X else { X printf(" Unknow profile, supported profiles:\n\n" X " DVD|SVCD|VCD|MPEG2|MPEG1|DVDS1|DVDS2|MPEG2_TS\n\n"); X exit (1); X } X X X X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "open() of /dev/cxm0 failed." ); X exit(1); X } X X if ( ioctl( cfd, CODEC_ASSIGN_ST, user_st ) < 0 ) { X perror( "ioctl( tfd, METEORSETGEO ) failed." ); X status = 1; X } X X X close ( cfd ); X exit ( status ); X} END-of-./examples/setprofile.c echo x - ./examples/setbitrate.c sed 's/^X//' >./examples/setbitrate.c << 'END-of-./examples/setbitrate.c' X#include <stdio.h> X#include <fcntl.h> X#include <sys/ioctl.h> X#include <stdlib.h> X#include "../ioctl_codec.h" X X/****************************************************************************/ X/* setbitrate.c - Set the bitrate of the cxm encoder card. */ X/* */ X/* COMPILE WITH: cc -o setbitrate setbitrate.c */ X/****************************************************************************/ X X Xstatic void Xusage() X{ X printf(" ##################################################################\n\n"); X printf( X " Usage: setbitrate x y z (where x = mode, y = average and z = peak)\n\n" X " Exemple: \n" X " Default DVD bitrate params: 0 9000 9520 \n\n" X " First value is for mode: VBR 0, CBR 1. If the CBR is selected peak must be 0\n" X " NOTE: VBR is unsupported by MPEG1 and VCD profiles \n\n" X " Average limits: Min 1150 kb/s Max 9520 kb/s\n\n" X ); X printf(" ##################################################################\n\n"); X} X Xint main( int argc, char *argv[] ) X{ X int status; X int cfd; X X struct codec_bitrate *user_bitrate; X X if (argc!=4) { X usage (); X exit (1); X } X X user_bitrate=(struct codec_bitrate *)calloc(sizeof(struct codec_bitrate),1); X X user_bitrate->mode = atoi(argv[1]); X user_bitrate->average = atoi(argv[2]) * 1000; X user_bitrate->peak = atoi(argv[3]) * 1000; X X status = 0; X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "open() of /dev/cxm0 failed." ); X exit(1); X } X X if ( ioctl( cfd, CODEC_ASSIGN_BITRATES, user_bitrate ) < 0 ) { X perror( "ioctl( cfd, CODEC_ASSIGN_BITRATES ) failed." ); X status = 1; X exit (1); X } X X printf("Setting to %d mode %d kb/s average %d kb/s peak \n",\ X user_bitrate->mode, user_bitrate->average / 1000, user_bitrate->peak /1000); X X close ( cfd ); X exit ( status ); X} END-of-./examples/setbitrate.c echo x - ./examples/setaudio.c sed 's/^X//' >./examples/setaudio.c << 'END-of-./examples/setaudio.c' X#include <stdio.h> X#include <fcntl.h> X#include <sys/ioctl.h> X#include <stdlib.h> X#include "../ioctl_codec.h" X X/****************************************************************************/ X/* setaudio.c - Set the audio type of the cxm encoder card. */ X/* */ X/* COMPILE WITH: cc -o setaudio setaudio.c */ X/****************************************************************************/ X X Xstatic void Xusage() X{ X printf(" #########################################################\n\n"); X printf(" Usage: setaudio <-a|-b|-c >\n\n" X " -a 384 kb/s 48 KH Layer 2 mode. \n\n" X " -b 224 kb/s 48 KH Layer 2 mode. \n\n" X " -c 192 kb/s 48 KH Layer 2 mode. \n\n" X " -d 384 kb/s 44.1 KH Layer 2 mode.\n\n" X " -e 224 kb/s 44.1 KH Layer 2 mode.\n\n" X " -f 192 kb/s 44.1 KH Layer 2 mode.\n\n"); X printf(" #########################################################\n\n"); X} X Xint main( int argc, char *argv[] ) X{ X char opt; X int status; X int cfd; X int audio_type; X X while ((opt = getopt (argc, argv, ":abcdef")) != -1) X switch (opt){ X case 'a': X audio_type = CODEC_AUDIO_L2_48_384; X printf("Setting to DVD, codec format: %d\n",audio_type); X break; X X case 'b': X audio_type = CODEC_AUDIO_L2_48_224; X printf("Setting to SVCD, codec format: %d\n",audio_type); X break; X X case 'c': X audio_type = CODEC_AUDIO_L2_48_192; X printf("Setting to SVCD, codec format: %d\n",audio_type); X break; X X case 'd': X audio_type = CODEC_AUDIO_L2_441_384; X printf("Setting to VCD, codec format: %d\n",audio_type); X break; X X case 'e': X audio_type = CODEC_AUDIO_L2_441_224; X printf("Setting to VCD, codec format: %d\n",audio_type); X break; X X case 'f': X audio_type = CODEC_AUDIO_L2_441_192; X printf("Setting to VCD, codec format: %d\n",audio_type); X break; X X default: X usage (); X exit (1); X break; X } X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "open() of /dev/cxm0 failed." ); X exit(1); X } X X if ( ioctl( cfd, CODEC_ASSIGN_AUDIO_PROP, &audio_type ) < 0 ) { X perror( "ioctl( tfd, METEORSETGEO ) failed." ); X status = 1; X } X X X close ( cfd ); X exit ( status ); X} END-of-./examples/setaudio.c echo x - ./examples/setaspect.c sed 's/^X//' >./examples/setaspect.c << 'END-of-./examples/setaspect.c' X#include <stdio.h> X#include <fcntl.h> X#include <sys/ioctl.h> X#include <stdlib.h> X#include "../ioctl_codec.h" X X#define EQ(str1, str2)(strcmp((str1), (str2)) == 0) X/****************************************************************************/ X/* setaspect.c - Set the aspect ratio of the cxm encoder card. */ X/* */ X/* COMPILE WITH: cc -o setaspect setaspect.c */ X/****************************************************************************/ X X Xstatic void Xusage() X{ X printf(" ####################################################\n\n"); X printf(" Usage: setaspect < 0:0 | 1:1 | 4:3 | 16:9 | 2.21:1 >\n\n" X " 0:0 forbidden mode. \n\n" X " 1:1 square mode. \n\n" X " 4:3 mode. \n\n" X " 16:9 mode. \n\n" X " 2.21:1 mode. \n\n"); X printf(" ####################################################\n\n"); X} X Xint main( int argc, char *argv[] ) X{ X int status; X int cfd; X unsigned int my_aspect; X X if (EQ (argv[1], "0:0")){ X my_aspect = CODEC_ASR_FORBBIDEN; X printf("Setting to aspect: %d (0:0)\n", my_aspect); X } X X else if (EQ (argv[1], "1:1")){ X my_aspect = CODEC_ASR_SQUARE; X printf("Setting to aspect: %d (1:1)\n", my_aspect); X } X X else if (EQ (argv[1], "4:3")){ X my_aspect = CODEC_ASR_4_3; X printf("Setting to aspect: %d (4:3)\n", my_aspect); X } X X else if (EQ (argv[1], "16:9")){ X my_aspect = CODEC_ASR_16_9; X printf("Setting to aspect: %d (16:9)\n", my_aspect); X } X X else if (EQ (argv[1], "2.21:1")){ X my_aspect = CODEC_ASR_FORBBIDEN; X printf("Setting to aspect: %d (2.21:1)\n", my_aspect); X } X X else { X usage (); X exit (1); X } X X cfd = open( "/dev/cxm0", O_RDONLY ); X if ( cfd < 0 ) { X perror( "open() of /dev/cxm0 failed." ); X exit(1); X } X X if ( ioctl( cfd, CODEC_ASSIGN_ASR, &my_aspect ) < 0 ) { X perror( "ioctl( tfd, METEORSETGEO ) failed." ); X status = 1; X } X X close ( cfd ); X exit ( status ); X} END-of-./examples/setaspect.c echo x - ./examples/Makefile sed 's/^X//' >./examples/Makefile << 'END-of-./examples/Makefile' Xall: setaspect.o setaudio.o setbitrate.o setprofile.o view-profile.o X cc setaspect.o -o pvr250-setaspect X cc setaudio.o -o pvr250-setaudio X cc setbitrate.o -o pvr250-setbitrate X cc setprofile.o -o pvr250-setprofile X cc view-profile.o -o pvr250-view-profile END-of-./examples/Makefile echo x - ./patch_cxm_h sed 's/^X//' >./patch_cxm_h << 'END-of-./patch_cxm_h' X--- dev/cxm/cxm.h.ORIGINAL X+++ dev/cxm/cxm.h X@@ -250,7 +250,7 @@ X X char msp_name[10]; X X- const struct cxm_codec_profile *profile; X+ struct cxm_codec_profile *profile; X X enum cxm_source source; X X@@ -430,6 +430,13 @@ X #define CXM_FW_STREAM_TYPE_MPEG2_PROGRAM 0x00000000 X #define CXM_FW_STREAM_TYPE_SVCD 0x0000000c X #define CXM_FW_STREAM_TYPE_VCD 0x0000000b X+/* More defines for stream types takes from ivtv project */ X+#define CXM_FW_STREAM_TYPE_MPEG2_TS 0x00000001 X+#define CXM_FW_STREAM_TYPE_PES_AV 0x00000003 X+#define CXM_FW_STREAM_TYPE_PES_V 0x00000005 X+#define CXM_FW_STREAM_TYPE_PES_A 0x00000007 X+#define CXM_FW_STREAM_TYPE_DVD_S1 0x0000000d X+#define CXM_FW_STREAM_TYPE_DVD_S2 0x0000000e X X #define CXM_MACROBLOCK_HEIGHT 16 X #define CXM_MACROBLOCK_WIDTH 16 END-of-./patch_cxm_h echo x - ./Makefile sed 's/^X//' >./Makefile << 'END-of-./Makefile' X XSUBDIR = XSUBDIR += src XSUBDIR += examples X X.include <bsd.subdir.mk> X Xpre-build: X /bin/cp ioctl_codec.h dev/cxm/ ; /usr/bin/patch < patch_cxm_c ; \ X/usr/bin/patch < patch_cxm_h ; /usr/bin/patch < patch_modules_cxm_cxm_Makefile X X Xinstall-dist: X /bin/cp src/pvr250-codecconf /usr/local/bin/ ;\ X/bin/mkdir /usr/local/share/examples/pvr250/ ; \ X/bin/cp -r examples/*.c ioctl_codec.h /usr/local/share/examples/pvr250/;\ X Xinstall-dist-examples: X /bin/cp examples/pvr250-* /usr/local/bin/ X END-of-./Makefile echo x - ./patch_cxm_c sed 's/^X//' >./patch_cxm_c << 'END-of-./patch_cxm_c' X--- dev/cxm/cxm.c.ORIGINAL X+++ dev/cxm/cxm.c X@@ -69,6 +69,7 @@ X # include <dev/bktr/ioctl_bt848.h> X #endif X X+ X #include <sys/bus.h> X #include <sys/rman.h> X X@@ -81,7 +82,7 @@ X #endif X X #include <dev/cxm/cxm.h> X- X+#include <dev/cxm/ioctl_codec.h> X X /* X * Various supported device vendors/types and their names. X@@ -168,7 +169,7 @@ X /* X * Various profiles. X */ X-static struct cxm_codec_profile vcd_ntsc_profile = { X+struct cxm_codec_profile vcd_ntsc_profile = { X "MPEG-1 VideoCD NTSC video and MPEG audio", X CXM_FW_STREAM_TYPE_VCD, X 30, X@@ -188,7 +189,7 @@ X 0xb8 X }; X X-static struct cxm_codec_profile vcd_pal_profile = { X+struct cxm_codec_profile vcd_pal_profile = { X "MPEG-1 VideoCD PAL video and MPEG audio", X CXM_FW_STREAM_TYPE_VCD, X 25, X@@ -208,7 +209,7 @@ X 0xb8 X }; X X-static struct cxm_codec_profile svcd_ntsc_profile = { X+struct cxm_codec_profile svcd_ntsc_profile = { X "MPEG-2 SuperVCD NTSC video and MPEG audio", X CXM_FW_STREAM_TYPE_SVCD, X 30, X@@ -229,7 +230,7 @@ X 0xb8 X }; X X-static struct cxm_codec_profile svcd_pal_profile = { X+struct cxm_codec_profile svcd_pal_profile = { X "MPEG-2 SuperVCD PAL video and MPEG audio", X CXM_FW_STREAM_TYPE_SVCD, X 25, X@@ -250,7 +251,7 @@ X 0xb8 X }; X X-static struct cxm_codec_profile dvd_ntsc_profile = { X+struct cxm_codec_profile dvd_ntsc_profile = { X "MPEG-2 DVD NTSC video and MPEG audio", X CXM_FW_STREAM_TYPE_DVD, X 30, X@@ -271,7 +272,7 @@ X 0xe9 X }; X X-static struct cxm_codec_profile dvd_pal_profile = { X+struct cxm_codec_profile dvd_pal_profile = { X "MPEG-2 DVD PAL video and MPEG audio", X CXM_FW_STREAM_TYPE_DVD, X 25, X@@ -292,14 +293,248 @@ X 0xe9 X }; X X-static const struct cxm_codec_profile X+struct cxm_codec_profile mpeg2_ntsc_profile = { X+ "MPEG-2 NTSC video and MPEG audio", X+ CXM_FW_STREAM_TYPE_MPEG2_PROGRAM, X+ 30, X+ 720, 480, 480, X+ { 10, 12, 21 }, X+ 2, X+ 0, X+ /* X+ * 8 Mb/s (size of BLOCKDEVICE)the best quality for realtime playback X+ * without losses and default cache size for mplayer and xine. X+ */ X+ { 0, 8000000, 8192000 }, X+ { 1, 15, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ X+ 0xe9 X+}; X+ X+struct cxm_codec_profile mpeg2_pal_profile = { X+ "MPEG-2 PAL video and MPEG audio", X+ CXM_FW_STREAM_TYPE_MPEG2_PROGRAM, X+ 25, X+ 720, 576, 576, X+ { 6, 17, 22 }, X+ 2, X+ 0, X+ /* X+ * 8 Mb/s (size of BLOCKDEVICE)the best quality for realtime playback X+ * without losses and default cache size for mplayer and xine. X+ */ X+ { 0, 8000000, 8192000 }, X+ { 1, 12, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ X+ 0xe9 X+}; X+ X+struct cxm_codec_profile mpeg1_ntsc_profile = { X+ "MPEG-1 NTSC video and MPEG audio", X+ CXM_FW_STREAM_TYPE_MPEG1, X+ 30, X+ 352, 240, 480, X+ { 10, 12, 21 }, X+ 12, X+ 0, X+ { 1, 1827000, 0 }, X+ { 1, 15, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 44.1 Khz, MPEG-1 Layer II, 224 kb/s */ X+ 0xb8 X+}; X+ X+struct cxm_codec_profile mpeg1_pal_profile = { X+ "MPEG-1 PAL video and MPEG audio", X+ CXM_FW_STREAM_TYPE_MPEG1, X+ 25, X+ 352, 288, 576, X+ { 6, 17, 22 }, X+ 8, X+ 0, X+ { 1, 1827000, 0 }, X+ { 1, 12, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 44.1 Khz, MPEG-1 Layer II, 224 kb/s */ X+ 0xb8 X+}; X+ X+struct cxm_codec_profile dvd_s1_ntsc_profile = { X+ "MPEG-2 DVD_S1 NTSC video and MPEG audio", X+ CXM_FW_STREAM_TYPE_DVD_S1, X+ 30, X+ 720, 480, 480, X+ { 10, 12, 21 }, X+ 2, X+ 0, X+ /* 4 Mb/s ~2Gb/h - Ideal for DVD5 -140 min. aprox. -*/ X+ { 0, 4000000, 4096000 }, X+ { 1, 15, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ X+ 0xe9 X+}; X+ X+struct cxm_codec_profile dvd_s1_pal_profile = { X+ "MPEG-2 DVD PAL video and MPEG audio", X+ CXM_FW_STREAM_TYPE_DVD_S1, X+ 25, X+ 720, 576, 576, X+ { 6, 17, 22 }, X+ 2, X+ 0, X+ /* 4 Mb/s ~2Gb/h - Ideal for DVD5 -140 min. aprox. -*/ X+ { 0, 4000000, 4096000 }, X+ { 1, 12, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ X+ 0xe9 X+}; X+ X+struct cxm_codec_profile dvd_s2_ntsc_profile = { X+ "MPEG-2 DVD_S2 NTSC video and MPEG audio", X+ CXM_FW_STREAM_TYPE_DVD_S2, X+ 30, X+ 720, 480, 480, X+ { 10, 12, 21 }, X+ 2, X+ 0, X+ /* X+ * 2 Mb/s peak ~1Gb/h For store 6 h in DVD5 and 12 h in DVD9 -Ideal for series- X+ */ X+ { 0, 2000000, 2048000 }, X+ { 1, 15, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 224 kb/s */ X+ 0xb9 X+}; X+ X+struct cxm_codec_profile dvd_s2_pal_profile = { X+ "MPEG-2 DVD PAL video and MPEG audio", X+ CXM_FW_STREAM_TYPE_DVD_S2, X+ 25, X+ 720, 576, 576, X+ { 6, 17, 22 }, X+ 2, X+ 0, X+ /* X+ * 2 Mb/s peak ~1Gb/h For store 6 h in DVD5 and 12 h in DVD9 -Ideal for series- X+ */ X+ { 0, 2000000, 2048000 }, X+ { 1, 12, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 224 kb/s */ X+ 0xb9 X+}; X+ X+struct cxm_codec_profile mpeg2_ts_ntsc_profile = { X+ "MPEG-2 NTSC video and MPEG audio", X+ CXM_FW_STREAM_TYPE_MPEG2_TS, X+ 30, X+ 720, 480, 480, X+ { 10, 12, 21 }, X+ 2, X+ 0, X+ /* X+ * Unknow good values. I don't have the datasheet. X+ * ONLY FOR TEST. X+ */ X+ { 0, 6000000, 6144000 }, X+ { 1, 15, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ X+ 0xe9 X+}; X+ X+struct cxm_codec_profile mpeg2_ts_pal_profile = { X+ "MPEG-2 PAL video and MPEG audio", X+ CXM_FW_STREAM_TYPE_MPEG2_TS, X+ 25, X+ 720, 576, 576, X+ { 6, 17, 22 }, X+ 2, X+ 0, X+ /* X+ * Unknow good values. I don't have the datasheet. X+ * ONLY FOR TEST. X+ */ X+ { 0, 6000000, 6144000 }, X+ { 1, 12, 3}, X+ /* X+ * Spatial filter = Manual, Temporal filter = Manual X+ * Median filter = Horizontal / Vertical X+ * Spatial filter value = 1, Temporal filter value = 4 X+ */ X+ { 0, 3, 1, 4 }, X+ /* 48 Khz, MPEG-1 Layer II, 384 kb/s */ X+ 0xe9 X+}; X+ X+struct cxm_codec_profile X *codec_profiles[] = { X &vcd_ntsc_profile, X &vcd_pal_profile, X &svcd_ntsc_profile, X &svcd_pal_profile, X &dvd_ntsc_profile, X- &dvd_pal_profile X+ &dvd_pal_profile, X+ &mpeg2_ntsc_profile, X+ &mpeg2_pal_profile, X+ &mpeg1_ntsc_profile, X+ &mpeg1_pal_profile, X+ &dvd_s1_ntsc_profile, X+ &dvd_s1_pal_profile, X+ &dvd_s2_ntsc_profile, X+ &dvd_s2_pal_profile, X+ &mpeg2_ts_ntsc_profile, X+ &mpeg2_ts_pal_profile X }; X X X@@ -785,7 +1020,7 @@ X int fps; X unsigned int i; X u_int32_t parameters[12]; X- const struct cxm_codec_profile *cpp; X+ struct cxm_codec_profile *cpp; X X fps = cxm_saa7115_detected_fps(sc); X X@@ -801,7 +1036,8 @@ X X for (i = 0; i < NUM_ELEMENTS(codec_profiles); i++) X if (codec_profiles[i]->fps == fps X- && codec_profiles[i]->width == sc->profile->width) X+ && codec_profiles[i]->width == sc->profile->width X+ && codec_profiles[i]->stream_type == sc->profile->stream_type) X break; X X if (i >= NUM_ELEMENTS(codec_profiles)) X@@ -2271,13 +2507,18 @@ X int result; X int status; X int unit; X+ int audio_type; X unsigned int i; X unsigned int sig; X+ unsigned int asr_mode; X unsigned long freq; X struct cxm_softc *sc; X enum cxm_source source; X struct bktr_capture_area *cap; X struct bktr_remote *remote; X+ struct assign_st *user_st; X+ struct codec_bitrate *user_bitrate; X+ struct cxm_user_ioctl_codec *current_codec; X intrmask_t s; X X unit = UNIT( minor(dev) ); X@@ -2849,7 +3090,106 @@ X if (cxm_ir_key(sc, (char *)remote, sizeof(*remote)) < 0) X return ENXIO; X break; X+ X+ X+/* My ioctl for switch between profiles*/ X+ case CODEC_ASSIGN_ST: X+ if (sc->encoding) X+ return EBUSY; X+ X+ user_st = (struct assign_st *)arg; X+ X+ /* X+ * Setting the stream type has the side effect of X+ * chosing between the VCD, SVCD, and DVD profiles. X+ */ X+ X+ for (i = 0; i < NUM_ELEMENTS(codec_profiles); i++) X+ if (codec_profiles[i]->stream_type == user_st->stream_type\ X+ && codec_profiles[i]->fps == user_st->stdtv) X+ break; X+ X+ if (i >= NUM_ELEMENTS(codec_profiles)) X+ return EINVAL; X+ X+ sc->profile = codec_profiles[i]; X+ break; X+ X+ case CODEC_ASSIGN_ASR: X+ asr_mode = *(unsigned int *)arg; X+ /* Clean bits, now '0000' */ X+ sc->profile->aspect = (sc->profile->aspect >> 4); X X+ if ( asr_mode == 0 ){ X+ sc->profile->aspect = (sc->profile->aspect ^ asr_mode); X+ } X+ else if ( asr_mode == 1 ){ X+ sc->profile->aspect = (sc->profile->aspect ^ asr_mode); X+ } X+ else if ( asr_mode == 2 ){ X+ sc->profile->aspect = (sc->profile->aspect ^ asr_mode); X+ } X+ else if (asr_mode == 3){ X+ sc->profile->aspect = (sc->profile->aspect ^ asr_mode); X+ } X+ else if ( asr_mode == 4 ){ X+ sc->profile->aspect = (sc->profile->aspect ^ asr_mode); X+ } X+ else X+ return EINVAL; X+ break; X+ X+ case CODEC_ASSIGN_BITRATES: X+ user_bitrate = (struct codec_bitrate *)arg; X+ if ((user_bitrate->mode < 0) || (user_bitrate->mode > 1)) X+ return EINVAL; X+ else if ((user_bitrate->mode == 0) && ((sc->profile->stream_type == CODEC_ST_VCD)\ X+ || (sc->profile->stream_type == CODEC_ST_MPEG1))) X+ return EINVAL; X+ else if ((user_bitrate->average < CODEC_MIN_BITRATE) \ X+ || (user_bitrate->average > CODEC_MAX_BITRATE)) X+ return EINVAL; X+ else if ((user_bitrate->mode == 0) && ((user_bitrate->average > user_bitrate->peak))) X+ return EINVAL; X+ else if ((user_bitrate->mode == 1) && (user_bitrate->peak != 0)) X+ return EINVAL; X+ else X+ sc->profile->bitrate.mode = user_bitrate->mode; X+ sc->profile->bitrate.average = user_bitrate->average; X+ sc->profile->bitrate.peak = user_bitrate->peak; X+ break; X+ X+ case CODEC_ASSIGN_AUDIO_PROP: X+ audio_type = *(int *)arg; X+ sc->profile->audio = audio_type; X+ break; X+ X+ case CODEC_USER_GPROP: X+ current_codec = (struct cxm_user_ioctl_codec *)arg; X+ memset (current_codec, 0, sizeof (*current_codec)); X+ current_codec->name = sc->profile->name; X+ current_codec->stream_type = sc->profile->stream_type; X+ current_codec->fps = sc->profile->fps; X+ current_codec->width = sc->profile->width; X+ current_codec->height = sc->profile->height; X+ current_codec->source_height = sc->profile->source_height; X+ current_codec->vbi.start = sc->profile->vbi.start; X+ current_codec->vbi.nlines = sc->profile->vbi.nlines; X+ current_codec->vbi.cc = sc->profile->vbi.cc; X+ current_codec->aspect = sc->profile->aspect; X+ current_codec->pulldown = sc->profile->pulldown; X+ current_codec->bitrate.mode = sc->profile->bitrate.mode; X+ current_codec->bitrate.average = sc->profile->bitrate.average; X+ current_codec->bitrate.peak = sc->profile->bitrate.peak; X+ current_codec->gop.closure = sc->profile->gop.closure; X+ current_codec->gop.frames = sc->profile->gop.frames; X+ current_codec->gop.bframes = sc->profile->gop.bframes; X+ current_codec->dnr.mode = sc->profile->dnr.mode; X+ current_codec->dnr.type = sc->profile->dnr.type; X+ current_codec->dnr.spatial = sc->profile->dnr.spatial; X+ current_codec->dnr.temporal = sc->profile->dnr.temporal; X+ current_codec->audio = sc->profile->audio; X+ break; X default: X return ENOTTY; X } END-of-./patch_cxm_c echo x - ./ioctl_codec.h sed 's/^X//' >./ioctl_codec.h << 'END-of-./ioctl_codec.h' X/* X * Copyright (c) 2005 X * Luis López Solé <cronopilopez@gmail.com>. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by John Wehle. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE X * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, X * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES X * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR X * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN X * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE X * POSSIBILITY OF SUCH DAMAGE. X * X * NOTE: This project had not been realized without John Wehle's previous X * work and the documenattion of ivtv project. X */ X X/* X* Header file - ioctl_codec.h - encoder ioctl's for cxm driver. X*/ X#include <sys/types.h> X X/* ASSIGN STREAM TYPE ioctl */ X#define CODEC_ASSIGN_ST _IOW('x', 185, struct assign_st) Xstruct assign_st{ X unsigned int stdtv; /* Needed for chose between NTSC/PAL/SECAM modes */ X unsigned long stream_type; X}; X/* Stream types supported (DVD, SVCD, VCD, MPEG1 and MPEG2_PROGRAM Xtakes from cxm.h, other values takes from ivtv project) */ X#define CODEC_ST_DVD 0x0000000a X#define CODEC_ST_MPEG1 0x00000002 X#define CODEC_ST_MPEG2_PROGRAM 0x00000000 X#define CODEC_ST_SVCD 0x0000000c X#define CODEC_ST_VCD 0x0000000b X#define CODEC_ST_MPEG2_TS 0x00000001 X#define CODEC_ST_PES_AV 0x00000003 X#define CODEC_ST_PES_V 0x00000005 X#define CODEC_ST_PES_A 0x00000007 X#define CODEC_ST_DVD_S1 0x0000000d X#define CODEC_ST_DVD_S2 0x0000000e X X/* ASSIGN ASPECT */ X#define CODEC_ASSIGN_ASR _IOW ('x', 153, unsigned int) X/* Supported aspect ratio*/ X#define CODEC_ASR_FORBBIDEN 0x00000000 X#define CODEC_ASR_SQUARE 0x00000001 X#define CODEC_ASR_4_3 0x00000002 X#define CODEC_ASR_16_9 0x00000003 X#define CODEC_ASR_221_1 0x00000004 X X X/* ASSIGN BITRATE */ X#define CODEC_ASSIGN_BITRATES _IOW ('x', 149, struct codec_bitrate) Xstruct codec_bitrate{ X unsigned short mode; X unsigned long average; X unsigned long peak; X}; X/* Limits */ X#define CODEC_MAX_BITRATE 9520000 X#define CODEC_MIN_BITRATE 1150000 X X/* ASSIGN AUDIO PROPERTYS */ X#define CODEC_ASSIGN_AUDIO_PROP _IOW ('x', 189, int) X/* Some available audio types (more are possible, cxm.h for details) */ X#define CODEC_AUDIO_L2_48_384 0xe9 X#define CODEC_AUDIO_L2_48_224 0xb9 X#define CODEC_AUDIO_L2_48_192 0xa9 X#define CODEC_AUDIO_L2_441_384 0xe8 X#define CODEC_AUDIO_L2_441_224 0xb8 X#define CODEC_AUDIO_L2_441_192 0xa8 X X X/* For read current profile (it's the same that cxm_codec_profile, see cxm.h) */ X#define CODEC_USER_GPROP _IOR ('x', 220, struct cxm_user_ioctl_codec) Xstruct cxm_user_ioctl_codec { X const char *name; X u_int32_t stream_type; X u_int32_t fps; X u_int32_t width; X u_int32_t height; X u_int32_t source_height; X struct { X u_int32_t start; X u_int32_t nlines; X u_int32_t cc; X } vbi; X u_int32_t aspect; X u_int32_t pulldown; X struct { X u_int32_t mode; X u_int32_t average; X u_int32_t peak; X } bitrate; X struct { X u_int32_t closure; X u_int32_t frames; X u_int32_t bframes; X } gop; X struct { X u_int32_t mode; X u_int32_t type; X u_int32_t spatial; X u_int32_t temporal; X } dnr; X X u_int32_t audio; X}; END-of-./ioctl_codec.h echo x - ./patch_modules_cxm_cxm_Makefile sed 's/^X//' >./patch_modules_cxm_cxm_Makefile << 'END-of-./patch_modules_cxm_cxm_Makefile' X--- modules/cxm/cxm/Makefile.ORIGINAL X+++ modules/cxm/cxm/Makefile X@@ -1,7 +1,7 @@ X .PATH: ${.CURDIR}/../../../dev/cxm X KMOD = cxm X SRCS = cxm.c cxm.h cxm_dec_fw.c cxm_enc_fw.c cxm_audio.c cxm_eeprom.c \ X- cxm_ir.c cxm_tuner.c cxm_video.c opt_cxm.h \ X+ cxm_ir.c cxm_tuner.c cxm_video.c ioctl_codec.h opt_cxm.h \ X bus_if.h device_if.h iicbb_if.h pci_if.h vnode_if.h X X .include <bsd.kmod.mk> END-of-./patch_modules_cxm_cxm_Makefile exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503021202.j22C2cjY008692>