本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2011-11/47800.htm
一.tvout_app的移植
为了测试S3C6410的电视输出,我拿了官方的tvout_app中的测试,这个做的相当初糙,好象是很老的版本,在更改了Makefile后编译,最后发现有函数未定义
/home/huisen/project/tvout/tvout_app/tv_test.c:450: undefined reference to `s3c_get_media_memory'
查看源码是这个原因造成的
ctrl.value = POST_BUFF_BASE_ADDR;
而这个宏是如下定义
#define POST_BUFF_BASE_ADDR (UINT32)s3c_get_media_memory(S3C_MDEV_TV)
这个应用程序直接调用驱动里的函数,这在LINUX是不可以的。我估计三星也没把这TVOUT当回事,直接就发布了,编译通不过也不管。虽然在培训上s3c6410用的很多,但是很多细节上来看,在花了很长时间做s3c2440后,三星匆忙推出s3c6410,然后大队人马就去搞s5p系列了。留一下一堆问题。
一种最简单方法是扩展s3c-tvenc的驱动,增加一个VIDIOC_G_CTRL的ioctl指令,让其在驱动中调用s3c_get_media_memory.
在s3c-tvenc.c 增加如下代码:
新增函数: s3c_tvenc_get_v4l2_control()
在s3c_tvenc_do_ioctl()增加命令支持
static int s3c_tvenc_get_v4l2_control(struct v4l2_control *ctrl)
{
switch(ctrl->id) {
case V4L2_CID_MPEG_STREAM_PID_VIDEO:
ctrl->value = tv_param.sp.SrcFrmSt;
return 0;
default:
return -EINVAL;
}
return 0;
}
static int s3c_tvenc_do_ioctl(struct inode *inode,struct file *filp,unsigned int cmd,void *arg)
{
// ...
/* add by Andrew Huang */
case VIDIOC_G_CTRL:
{
struct v4l2_control *ctrl = arg;
//printk("P: VIDIOC_S_CTRL \n");
ret = s3c_tvenc_get_v4l2_control(ctrl);
return ret;
}
// ...
}
修改tv_test.c 代码,增加对上述ioctl命令的调用
修改 450行,增加如下代码
//add by Andrew Huang
#if 1
ret = ioctl(tvout_fp, VIDIOC_G_CTRL, &ctrl);
if(ret < 0) {
printf("V4L2 APPL : ioctl(VIDIOC_G_CTRL) failed\n");
goto err;
}
#else
//ctrl.value = POST_BUFF_BASE_ADDR; // 编译通不过
#endif
去掉一些编译警告后,可以测试了。
[root@huisen tvout_app]# make clean
rm -f tv_test ./tv_test.o ./FrameExtractor.o ./SsbSipH264Decode.o ./H264Frames.o ./SsbSipMfcDecode.o ./SsbSipLogMsg.o
[root@huisen tvout_app]# make
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -c -o tv_test.o tv_test.c
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -c -o FrameExtractor.o FrameExtractor.c
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -c -o SsbSipH264Decode.o SsbSipH264Decode.c
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -c -o H264Frames.o H264Frames.c
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -c -o SsbSipMfcDecode.o SsbSipMfcDecode.c
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -c -o SsbSipLogMsg.o SsbSipLogMsg.c
arm-linux-gcc -Wall -O0 -lpthread -I/home/huisen/rom/mini6410/linux-2.6.28.6/include -I. -g -o tv_test ./tv_test.o ./FrameExtractor.o ./SsbSipH264Decode.o ./H264Frames.o ./SsbSipMfcDecode.o ./SsbSipLogMsg.o -lpthread
本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2011-11/47800.htm