Internet & Web Application

เตรียมเล่น DreamBox ด้วย EasyCap 2.0 + Driver บน Linux

เตรียมตัวเล่น DreamBox 500-s จึงเตรียมอุปกรณ์รับ AV-input เพื่อความสะดวกในการ Setup .. แต่พอเริ่มต้น ความไม่สะดวกก็เริ่มก่อนเลย .. เนื่องจาก EasyCap 2.0 AV-in USB ไม่มี Device Driver อยุ่ Linux main stream

ดังนั้น จึงต้อง Search .. .. ..

ผลที่ได้ โชคดีที่มีคนดี ทำ Driver ไว้ให้แล้ว ..แต่ต้องมา Compile และทดสอบเอง โดย อ้างอิงตาม เอกสารต่อไปนี้

การทดสอบทำใน mplayer

สรุปเป็นขั้นตอนคือ

1. ใช้ Linux 2.6.32 และมี Header ได้ compile linux device driver module

2. Load easycap_dc60.0.9 เพื่อมา compile ให้ได้ easycap.ko

3. ข้างใน ทำการแก้ไข install_simple.sh เพื่อจะได้ไม่ต้องเป็น Root ในการ compile นิดหน่อยก่อน run> install_simple.sh

~~~ #
#        *************************************************************
#        *                                                           *
#        *     Ordinarily nothing below here needs to be changed.    *
#        *                                                           *
#        *************************************************************
#
#
#—————————————————————————–
#  CHECK THAT ESSENTIAL COMPONENTS ARE PRESENT
#—————————————————————————–
#if [ “x`whoami`” != “xroot” ]; then
#  echo “ERROR:  must be run as root”
#  exit 1
#fi

if [ “x`which gcc`” = “x” ]; then
echo “ERROR:  cannot find gcc.  Is it installed?”
exit 1
fi
if [ ! -x `which gcc` ]; then
echo “ERROR:  cannot execute gcc.  Is it installed correctly?”
exit 1
fi
if [ “x`which make`” = “x” ]; then
echo “ERROR:  cannot find make.  Is it installed?”
exit 1
fi
if [ ! -x `which make` ]; then
echo “ERROR:  cannot execute make.  Is it installed correctly?”
exit 1
fi
if [ ! -d “/usr/src” ]; then
echo “ERROR:  cannot find directory /usr/src”
echo ”        Are the kernel headers installed?”
exit 1
fi
DEPMODDIR=/lib/modules/`uname -r`
if [ ! -d ${DEPMODDIR} ]; then
echo “ERROR: directory not found: ${DEPMODDIR}”
exit 1
fi
SUBMODDIR=kernel/drivers/media/video
KERNELDIR=${DEPMODDIR}/build
if [ ! -d “${KERNELDIR}” ]; then
echo “ERROR:  cannot find directory ${KERNELDIR}”
echo ”        Are the kernel headers installed correctly?”
exit 1
fi
#—————————————————————————–

WORKDIR=`pwd`

#—————————————————————————–
LSMODOUT=`lsmod | grep “^easycap ” – | sed -e “s, .*$,,” – `
if [ “xeasycap” = “x${LSMODOUT}” ]; then rmmod easycap; fi
LSMODOUT=`lsmod | grep “^easycap ” – | sed -e “s, .*$,,” – `
if [ “xeasycap” = “x${LSMODOUT}” ]; then
echo “ERROR:  easycap module cannot be removed”
exit 1
fi
#—————————————————————————–
#LSMODOUT=`lsmod | grep “^snd_usb_audio ” – | sed -e “s, .*$,,” – `
#if [ “xsnd_usb_audio” = “x${LSMODOUT}” ]; then rmmod snd_usb_audio; fi
#LSMODOUT=`lsmod | grep “^snd_usb_audio ” – | sed -e “s, .*$,,” – `
#if [ “xsnd_usb_audio” = “x${LSMODOUT}” ]; then
#  echo “ERROR:  snd_usb_audio module cannot be removed”
#  exit 1
#fi
#—————————————————————————–
LSMODOUT=`lsmod | grep “^stk11xx ” – | sed -e “s, .*$,,” – `
if [ “xstk11xx” = “x${LSMODOUT}” ]; then rmmod stk11xx; fi
LSMODOUT=`lsmod | grep “^stk11xx ” – | sed -e “s, .*$,,” – `
if [ “xstk11xx” = “x${LSMODOUT}” ]; then
echo “ERROR:  stk11xx module cannot be removed”
exit 1
fi
#—————————————————————————–
mkdir -p ${DEPMODDIR}/${SUBMODDIR}
if [ ! -d ${DEPMODDIR}/${SUBMODDIR} ]; then
echo “ERROR:  directory not found: ${DEPMODDIR}/${SUBMODDIR}”
exit 1
fi
#—————————————————————————–
#if [ -e ${DEPMODDIR}/${SUBMODDIR}/easycap.ko ]; then
#  rm ${DEPMODDIR}/${SUBMODDIR}/easycap.ko
#fi
#if [ -e ${DEPMODDIR}/${SUBMODDIR}/easycap.ko ]; then
#  echo “ERROR:  file cannot be deleted: ${DEPMODDIR}/${SUBMODDIR}/easycap.ko”
#  exit 1
#fi
#—————————————————————————–
#depmod -a -v 1>${WORKDIR}/depmod.out 2>${WORKDIR}/depmod.err
#if [ 0 -ne $? ]; then
#  echo “ERROR:  step failed:  depmod”
#  cat ${WORKDIR}/depmod.err
#  exit 1
#else
#  echo “depmod OK”
#fi
#—————————————————————————–
if [ ! -d ${WORKDIR} ]; then
echo “ERROR: directory not found: ${WORKDIR}”
exit 1
fi
cd ${WORKDIR}
if [ “.${WORKDIR}” != “.`pwd`” ]; then
echo “ERROR:  cannot access working directory:  ${WORKDIR}”
exit 1
fi

>/${WORKDIR}/make.out
>/${WORKDIR}/make.err

#—————————————————————————–
# CREATE Makefile, src/Makefile AND tools/Makefile FROM DEFAULTS
#—————————————————————————–
if [ ! -e ${WORKDIR}/Makefile_default ]; then
echo “ERROR: file not found: ${WORKDIR}/Makefile_default”
exit 1
fi
if [ -e ${WORKDIR}/Makefile ]; then rm ${WORKDIR}/Makefile; fi
if [ -e ${WORKDIR}/Makefile ]; then
echo “ERROR: file cannot be removed: ${WORKDIR}/Makefile”
exit 1
fi
cp -p ${WORKDIR}/Makefile_default ${WORKDIR}/Makefile

if [ “x” != “x`uname -r | grep “2\.6\.36″ -`” ]; then
echo “unlocked_ioctl required”
if [ ! -e ${WORKDIR}/src/Makefile_2.6.36 ]; then
echo “ERROR: file not found: ${WORKDIR}/src/Makefile_2.6.36”
exit 1
fi
if [ -e ${WORKDIR}/src/Makefile ]; then rm ${WORKDIR}/src/Makefile; fi
if [ -e ${WORKDIR}/src/Makefile ]; then
echo “ERROR: file cannot be removed: ${WORKDIR}/src/Makefile”
exit 1
fi
cp -p ${WORKDIR}/src/Makefile_2.6.36 ${WORKDIR}/src/Makefile
else
echo “unlocked_ioctl not required”
if [ ! -e ${WORKDIR}/src/Makefile_default ]; then
echo “ERROR: file not found: ${WORKDIR}/src/Makefile_default”
exit 1
fi
if [ -e ${WORKDIR}/src/Makefile ]; then rm ${WORKDIR}/src/Makefile; fi
if [ -e ${WORKDIR}/src/Makefile ]; then
echo “ERROR: file cannot be removed: ${WORKDIR}/src/Makefile”
exit 1
fi
cp -p ${WORKDIR}/src/Makefile_default ${WORKDIR}/src/Makefile
fi

if [ ! -e ${WORKDIR}/tools/Makefile_default ]; then
echo “ERROR: file not found: ${WORKDIR}/tools/Makefile_default”
exit 1
fi
if [ -e ${WORKDIR}/tools/Makefile ]; then rm ${WORKDIR}/tools/Makefile; fi
if [ -e ${WORKDIR}/tools/Makefile ]; then
echo “ERROR: file cannot be removed: ${WORKDIR}/tools/Makefile”
exit 1
fi
cp -p ${WORKDIR}/tools/Makefile_default ${WORKDIR}/tools/Makefile
#—————————————————————————–
if [ ! -e ${WORKDIR}/Makefile ]; then
echo “ERROR: file not found: ${WORKDIR}/Makefile”
exit 1
fi
if [ ! -e ${WORKDIR}/src/Makefile ]; then
echo “ERROR: file not found: ${WORKDIR}/src/Makefile”
exit 1
fi
if [ ! -e ${WORKDIR}/tools/Makefile ]; then
echo “ERROR: file not found: ${WORKDIR}/tools/Makefile”
exit 1
fi

make clean 1>>${WORKDIR}/make.out 2>>${WORKDIR}/make.err

if [ \( 0 -ne $? \) -o \( -s ${WORKDIR}/make.err \) ]; then
echo “ERROR:  step failed:  make clean”
cat ${WORKDIR}/make.err
exit 1
else
echo “make clean OK”
fi

if [ -e ${WORKDIR}/src/easycap.ko ]; then
echo “ERROR:  file cannot be deleted: ${WORKDIR}/src/easycap.ko”
exit 1
fi

make 1>>${WORKDIR}/make.out 2>>${WORKDIR}/make.err

if [ \( 0 -ne $? \) -o \( -s ${WORKDIR}/make.err \) ]; then
echo “ERROR:  step failed:  make”
cat ${WORKDIR}/make.err
exit 1
else
echo “make OK”
fi
rm ${WORKDIR}/make.out

if [ ! -e ${WORKDIR}/src/easycap.ko ]; then
echo “ERROR:  cannot make file: ${WORKDIR}/src/easycap.ko”
exit 1
fi

exit 0

#—————————————————————————–
cp -p ${WORKDIR}/src/easycap.ko ${DEPMODDIR}/${SUBMODDIR}
if [ ! -e ${DEPMODDIR}/${SUBMODDIR}/easycap.ko ]; then
echo “ERROR:  file not found: ${DEPMODDIR}/${SUBMODDIR}/easycap.ko”
exit 1
else
echo “copied OK”
fi
#—————————————————————————–
depmod -a -v 1>${WORKDIR}/depmod.out 2>${WORKDIR}/depmod.err
if [ 0 -ne $? ]; then
echo “ERROR:  step failed:  depmod”
cat ${WORKDIR}/depmod.err
exit 1
else
echo “depmod OK”
fi
rm ${WORKDIR}/depmod.out
#—————————————————————————–
>${WORKDIR}/modprobe.out
>${WORKDIR}/modprobe.err

if [ -e “/etc/modprobe.d/easycap.conf” ]; then
rm /etc/modprobe.d/easycap.conf
fi

1>>${WORKDIR}/modprobe.out 2>>${WORKDIR}/modprobe.err \
modprobe easycap

if [ 0 -ne $? ]; then
echo “ERROR:  step failed:  modprobe”
cat ${WORKDIR}/modprobe.err
exit 1
fi
LSMODOUT=`lsmod | grep “^easycap ” – | sed -e “s, .*$,,” – `
if [ “easycap” != “${LSMODOUT}” ]; then
echo “ERROR:  easycap module not present”
exit 1
fi
echo “modprobe OK”
rm ${WORKDIR}/modprobe.out
if [ -e ${WORKDIR}/src/easycap.mod.c ]; then
rm ${WORKDIR}/src/easycap.mod.c
fi
#—————————————————————————–
if [ -e “./57-easycap.rules” ]; then
if [ -d “/etc/udev/rules.d” ]; then
if [ -e “/etc/udev/rules.d/57-easycap.rules” ]; then
echo “not overwriting /etc/udev/rules.d/57-easycap.rules”
else
cp -p ./57-easycap.rules /etc/udev/rules.d
if [ -x /etc/init.d/udev ]; then /etc/init.d/udev restart; fi
fi
else
echo “ERROR: directory not found: /etc/udev/rules.d”
fi
else
echo “ERROR: file not found: ./57-easycap.rules”
fi
exit 0

4. easycap.ko อยู่ใน easycap_dc60.0.9/src … ให้ ทดสอบโดย
> sudo insmod easycap.ko

5. เสียบ EasyCap USB

ุ6. จะปรากฏ /dev/easycap0 ขึ้น .. ถ้าเป็น Video .. และเป็น /dev/easysnd0 ถ้าเป็น sound (แต่ต้องมีการ rmmod snd_usb_audio ด้วย .. ถ้าต้องการเสียง)

7. ทดสอบด้วย (แบบไม่ต้องการเสียง)
> sudo mplayer tv:// -tv device=/dev/easycap0:input=1:fps=25

.. ภายที่ได้ชัดเจนมาก ..

Advertisements
มาตรฐาน

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s