📄 mjpeg_config.c
字号:
/* * mjpeg_config.c * * Copyright(C) 2003 Dojip Kim <greendrm@chipsbrain.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; with out 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, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <sys/ioctl.h>#include "ncplus_mjpeg.h"static void usage(void);static char read_key(void);//static int select_video(int fd);//static int set_register(int fd);//static int read_value(void);static void usage(void){ printf("Choose what you want to do 0: Reset q: Quit\n");}static char read_key(void){ char buffer[BUFSIZ]; //int i; read(0, buffer, BUFSIZ); return (buffer[0]);}#if 0static int select_video(int fd){ unsigned long i; char cmd; printf("Select video input (0-3) :"); fflush(stdout); cmd = read_key(); switch (cmd) { case '0': i = 0; break; case '1': i = 1; break; case '2': i = 2; break; case '3': i = 3; break; default: return -1; } ioctl(fd, SAA_IOCTSELVIDEO, i); return 0;}static int set_register(int fd){ unsigned long arg; arg = (unsigned long)read_value(); ioctl(fd, SAA_IOCTSETREG, arg); return 0;}#endif/* * 0x0000 00 00 * 0x0000[val][reg] *//*static int read_value(void){ int i = 0; int arg = 0; printf ("Enter register address (hex type) : "); fflush (stdout); scanf ("%x", &i); //printf ("0x%02x\n", i); arg |= (i & 0xff); printf ("Enter register value (hex type) : "); fflush (stdout); scanf ("%x", &i); //printf ("0x%02x\n", i); arg |= ( (i & 0xff) << 8 ); return arg;}*/int main(void){ int fd; char cmd;#if 1 if ((fd = open("/dev/mjpeg", O_RDWR)) < 0) { return -1; }#endif while(1) { usage(); printf("Enter the command : "); fflush(stdout); cmd = read_key(); /* if (cmd < '0' || cmd > '9') continue; */ switch(cmd) { case '0': ioctl(fd, MJPEG_IOCRESET); break; case 'q': exit(0); default: continue; } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -