embedded linux ,android

2010年11月12日 星期五

[轉]Android学习笔记之mainfest文件中android属性


以前的零散笔记, 共享一下, 有错误的地方还请指正。

android:allowTaskReparenting

是否允许activity更换从属的任务,比如从短信息任务 切换到浏览器任务。
--------------------------------------------------------------------------------------
android:alwaysRetainTaskState

是否保留状态不变, 比如切换回home, 再从新打开, activity处于最后的状态
--------------------------------------------------------------------------------------
android:clearTaskOnLanunch

比如 P 是 activity, Q 是被P 触发的 activity, 然后返回Home, 从新启动 P, 是否显示 Q
--------------------------------------------------------------------------------------
android:configChanges

当配置list发生修改时, 是否调用 onConfigurationChanged() 方法  比如 "locale|navigation|orientation".
--------------------------------------------------------------------------------------

android:enabled

activity 是否可以被实例化,
--------------------------------------------------------------------------------------

android:excludeFromRecents

是否可被显示在最近打开的activity列表里
--------------------------------------------------------------------------------------
android:exported

是否允许activity被其它程序调用
--------------------------------------------------------------------------------------
android:finishOnTaskLaunch

是否关闭已打开的activity当用户重新启动这个任务的时候
--------------------------------------------------------------------------------------
android.icon
--------------------------------------------------------------------------------------
android:label
--------------------------------------------------------------------------------------
android:launchMode

activity启动方式,  "standard" "singleTop"  "singleTask" "singleInstance"  其中前两个为一组, 后两个为一组
--------------------------------------------------------------------------------------

android:multiprocess
允许多进程
--------------------------------------------------------------------------------------
android:name

activity的类名, 必须指定

--------------------------------------------------------------------------------------
android:onHistory
是否需要移除这个activity当用户切换到其他屏幕时。 这个属性是 API level 3 中引入的
--------------------------------------------------------------------------------------

android:permission
--------------------------------------------------------------------------------------
android:process
一个activity运行时所在的进程名, 所有程序组件运行在应用程序默认的进程中,这个进程名跟应用程序的包名一致。<application>中的元素process属性能够为所有组件设定一个新的默认值。但是任何组件都可以覆盖这个默认值,允许你将你的程序放在多进程中运行。  如果这个属性被分配的名字以:开头, 当这个activity运行时, 一个新的专属于这个程序的进程将会被创建。 如果这个进程名以小写字母开头, 这个activity将会运行在全局的进程中,被它的许可所提供。
--------------------------------------------------------------------------------------

android:screenOrientation

activity显示的模式,  "unspecified" 默认值  "landscape" 风景画模式,宽度比高度大一些  "portrait" 肖像模式, 高度比宽度大。  "user" 用户的设置  "behind"  "sensor" "nosensor"

--------------------------------------------------------------------------------------

android:stateNotNeeded

是否 activity被销毁和成功重启并不保存状态

--------------------------------------------------------------------------------------

android:taskAffinity

activity的亲属关系, 默认情况同一个应用程序下的activity有相同的关系

--------------------------------------------------------------------------------------

android:theme

activity的样式主题, 如果没有设置,则activity的主题样式从属于应用程序, 参见<application>元素的theme属性
--------------------------------------------------------------------------------------

android:windowSoftInputMode

activity主窗口与软键盘的交互模式, 自从API level 3 被引入



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/k7sem/archive/2009/09/07/4527250.aspx

2010年11月11日 星期四

Surveyor

Project:   Surveyor
Product:  NAS ( Network Attached Storage )
Solution: Marvell 88F6180 BSP





































Patch
patch_rootfs.sh
#!/bin/sh

. ./scripts/build_subr.sh

#cd ${TOPDIR}/rootfs/dev 
#mknod /dev/nfs b 0 255

touch ${TOPDIR}/rootfs/etc/resolv.conf
chmod 644 ${TOPDIR}/rootfs/etc/resolv.conf

cp ${TOPDIR}/patch/sysconf/services ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/smb.conf ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/issue ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/group ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/passwd ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/fstab ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/inittab.patch ${TOPDIR}/rootfs/etc
cd ${TOPDIR}/rootfs/etc
patch -p0 < inittab.patch
rm -f inittab.patch

chmod 644 ${TOPDIR}/rootfs/etc/inittab ${TOPDIR}/rootfs/etc/fstab

cp -f ${TOPDIR}/patch/sysconf/rcS ${TOPDIR}/rootfs/etc/init.d

mkdir ${TOPDIR}/rootfs/tmp ${TOPDIR}/rootfs/mnt ${TOPDIR}/rootfs/sys
chmod 1777 ${TOPDIR}/rootfs/tmp

mkdir ${TOPDIR}/rootfs/var/lib ${TOPDIR}/rootfs/var/log ${TOPDIR}/rootfs/var/run ${TOPDIR}/rootfs/var/tmp  
chmod 1777 ${TOPDIR}/rootfs/var/tmp

mkdir ${TOPDIR}/rootfs/syrmnt ${TOPDIR}/rootfs/smbmnt

mknod ${TOPDIR}/rootfs/dev/FLK_gpio c 254 0

echo "Done"
patch_server.sh
#!/bin/sh

. ./scripts/build_subr.sh

echo "===start server==="
echo "**此script必須在pwd=/home/surveyor/rootfs下執行 ./scripts/patch_server.sh**"
echo "1. roofs放在/home/surveyor下"
echo "2. uImage放在/home/surveyor/kernel/linux-2.6.22.18-bin下"
echo "3. 請先安裝dhcp-3.0.6-12.fc8"
echo "4. 請先安裝tftp-0.42-5-fc8"
echo "5. 請先安裝nfs-utils-1.1.0-6.fc8"
echo "6. 請先安裝squashfs-tools"
echo "7. 更改uboot env,請參照.../patch/fedora8/uboot_env.conf"

echo "Setting IP"
ifdown eth0
ifconfig eth0 192.168.1.100
ifup eth0

echo "Satrting DHCP"
cp -f ${TOPDIR}/patch/fedora8/dhcpd.conf /etc
/etc/init.d/dhcpd restart

echo "Satrting TFTP"
cp -f ${TOPDIR}/patch/fedora8/tftp /etc/xinetd.d
service xinetd restart

echo "Satrting NFS"
cp -f ${TOPDIR}/patch/fedora8/exports /etc/
/etc/init.d/rpcbind restart
/etc/init.d/nfs restart

echo "Install squashfs"
modprobe squashfs

echo "===Down==="
build_squashfs.sh
#! /bin/sh

. ./scripts/build_subr.sh

today=`date +%Y%m%d`

mksquashfs ./rootfs ./rootfs.image/rootfs.$today.sqfs

chmod +r ./rootfs.image/rootfs.$today.sqfs

cp -f ./rootfs.image/rootfs.$today.sqfs /home/surveyor/kernel/linux-2.6.22.18-bin


Host Env
dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample  
#

ddns-update-style interim;
ignore client-updates;
allow bootp;

subnet 192.168.1.0 netmask 255.255.255.0 {

 range dynamic-bootp 192.168.1.50 192.168.1.60;
 default-lease-time 21600;
 max-lease-time 43200;

      host surveyor {
           hardware ethernet 00:50:43:52:02:29;
           fixed-address 192.168.1.99;
           next-server 192.168.1.3;
           filename "uImage";
           option root-path "/home/surveyor/rootfs/rootfs";
        }

}
exports
/home/surveyor/rootfs/rootfs *(rw,no_root_squash)
tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol.  The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
 socket_type  = dgram
 protocol  = udp
 wait   = yes
 user   = root
 server  = /usr/sbin/in.tftpd
 server_args  = -c -s /home/surveyor/kernel/linux-2.6.22.18-bin
# disable  = yes
 per_source  = 11
 cps   = 100 2
 flags   = IPv4
}
Uboot Env
nfs_boot:
setenv console 'console=ttyS0,115200'
setenv bootargs '$(console) $(bootargs_root) ip=dhcp nfsroot=192.168.1.100:/home/surveyor/rootfs/rootfs'
setenv bootcmd 'nand read 0x2000000 0x300000 0x300000;setenv bootargs $(console) $(mtdparts) $(bootargs_root) ip=dhcp nfsroot=192.168.1.100:/home/surveyor/rootfs/rootfs; bootm 0x2000000;'
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'

mtd_boot:
setenv mtdid 'nand0=nand_mtd'
setenv mtdparts 'mtdparts=nand_mtd:0x100000@0(uboot)ro,0x100000@0x100000(system1),0x100000@0x200000(system2),0x300000@0x300000(kernel)ro,0x700000@0x600000(RootFS)ro'
setenv bootcmd 'nand read 0x2000000 0x300000 0x300000 ;setenv bootargs $(console) ip=dhcp $(mtdparts) rootfstype=squashfs root=/dev/mtdblock5;bootm 0x2000000;'
setenv console 'console=ttyS0,115200'
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'

burn to flash:
tftpboot 0x1000000 uImage.20090514
nand erase 0x300000 0x300000
nand write 0x1000000 0x300000 0x300000

tftpboot 0x1000000 rootfs.20090514.sqsh
nand erase 0x600000 0x700000
nand write 0x1000000 0x600000 0x700000
Intergrate BSP
fstab
#/dev/nfs   /          nfs       defaults         0    0
proc       /proc      proc      defaults         0    0
devpts     /dev/pts   devpts    gid=4,mode=620   0    0
sysfs      /sys       sysfs     defaults         0    0
group
root:x:0:root
nobody:x:500:
inittab.patch
--- inittab 2005-12-18 18:52:42.000000000 +0800
+++ inittab.new 2009-05-09 10:41:44.000000000 +0800
@@ -1,6 +1,38 @@
+#/**+===========================================================================
+#File: inittab
+#
+#Description: be parsed for /sbin/init 
+#
+#Revision: V1.0
+#
+#History: 
+#+------------------+-------------+--------------------------------------------+
+#|  date         |   author   |       comments                  |
+#+------------------+-------------+--------------------------------------------+
+#| 2009/05/06    | Wade Chiu  |        Initial build                 |
+#+------------------+-------------+--------------------------------------------+
+#
+#-------------------------------------------------------------------------------
+#** Cheng Uei Precision Industry CONFIDENTIAL
+#** Copyright(C) 2009 Uei Precision Industry Co., Ltd. All Rights Reserved.
+#**
+#** The source code contained or described herein and all documents related
+#** to the source code (Material) are owned by Cheng Uei.
+#** The Material is protected by worldwide copyright and trade secret laws and
+#** treaty provisions. No part of the Material may be used, copied, reproduced,
+#** modified, published, uploaded, posted, transmitted, distributed, or disclosed
+#** in any way without Cheng Uei prior express written permission.
+#============================================================================+*/
+
+#==========================================
+# sysinit script
+#==========================================
 ::sysinit:/etc/init.d/rcS
-::respawn:-/bin/sh
-#::respawn:-/bin/sh
-#tty2::askfirst:-/bin/sh
-#::ctrlaltdel:/bin/umount -a -r
+
+#==========================================
+# respawn
+#==========================================
+# Put a getty on the serial port
+ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
+
issue
Foxlink NAS release 1 (Serveyor)
passwd
root:$1$$oCLuEVgI1iAqOA8pwkzAg1:0:0:root:/root:/bin/sh
nobody:x:500:500:Linux User,,,:/home/nobody:/bin/sh
rcS
#!/bin/bash

echo "Mounting file system"
/bin/mount -a

ifconfig | head -n 1 | awk '{print $5}' | awk '{FS=":"} {print "RPL"$4$5$6}' | xargs hostname

#execute flk_main_program

echo "Mounting shares"
ntfs-3g -o rw,noatime,nodirtime,remove_hiberfile,streams_interface=windows /dev/sda1 /tmp > /dev/null 2>&1

echo "allow_restart"
echo 1 > /sys/block/sda/device/scsi_disk*/allow_restart

echo "Starting telnet"
/usr/sbin/telnetd -f /etc/issue

echo "Starting samba"
/sbin/nmbd -D -s/etc/smb.conf 
/sbin/smbd -D -s/etc/smb.conf
services
# /etc/services:
# $Id: services,v 1.1 2004/10/09 02:49:18 andersen Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
# are included, only the more common ones.

tcpmux  1/tcp    # TCP port service multiplexer
echo  7/tcp
echo  7/udp
discard  9/tcp  sink null
discard  9/udp  sink null
systat  11/tcp  users
daytime  13/tcp
daytime  13/udp
netstat  15/tcp
qotd  17/tcp  quote
msp  18/tcp    # message send protocol
msp  18/udp    # message send protocol
chargen  19/tcp  ttytst source
chargen  19/udp  ttytst source
ftp-data 20/tcp
ftp  21/tcp
ssh  22/tcp    # SSH Remote Login Protocol
ssh  22/udp    # SSH Remote Login Protocol
telnet  23/tcp
# 24 - private
smtp  25/tcp  mail
# 26 - unassigned
time  37/tcp  timserver
time  37/udp  timserver
rlp  39/udp  resource # resource location
nameserver 42/tcp  name  # IEN 116
whois  43/tcp  nicname
re-mail-ck 50/tcp    # Remote Mail Checking Protocol
re-mail-ck 50/udp    # Remote Mail Checking Protocol
domain  53/tcp  nameserver # name-domain server
domain  53/udp  nameserver
mtp  57/tcp    # deprecated
bootps  67/tcp    # BOOTP server
bootps  67/udp
bootpc  68/tcp    # BOOTP client
bootpc  68/udp
tftp  69/udp
gopher  70/tcp    # Internet Gopher
gopher  70/udp
rje  77/tcp  netrjs
finger  79/tcp
www  80/tcp  http  # WorldWideWeb HTTP
www  80/udp    # HyperText Transfer Protocol
link  87/tcp  ttylink
kerberos 88/tcp  kerberos5 krb5 # Kerberos v5
kerberos 88/udp  kerberos5 krb5 # Kerberos v5
supdup  95/tcp
# 100 - reserved
hostnames 101/tcp  hostname # usually from sri-nic
iso-tsap 102/tcp  tsap  # part of ISODE.
csnet-ns 105/tcp  cso-ns  # also used by CSO name server
csnet-ns 105/udp  cso-ns
# unfortunately the poppassd (Eudora) uses a port which has already
# been assigned to a different service. We list the poppassd as an
# alias here. This should work for programs asking for this service.
# (due to a bug in inetd the 3com-tsmux line is disabled)
#3com-tsmux 106/tcp  poppassd
#3com-tsmux 106/udp  poppassd
rtelnet  107/tcp    # Remote Telnet
rtelnet  107/udp
pop-2  109/tcp  postoffice # POP version 2
pop-2  109/udp
pop-3  110/tcp    # POP version 3
pop-3  110/udp
sunrpc  111/tcp  portmapper # RPC 4.0 portmapper TCP
sunrpc  111/udp  portmapper # RPC 4.0 portmapper UDP
auth  113/tcp  authentication tap ident
sftp  115/tcp
uucp-path 117/tcp
nntp  119/tcp  readnews untp # USENET News Transfer Protocol
ntp  123/tcp
ntp  123/udp    # Network Time Protocol
netbios-ns 137/tcp    # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp    # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp    # NETBIOS session service
netbios-ssn 139/udp
swat  901/tcp
imap2  143/tcp    # Interim Mail Access Proto v2
imap2  143/udp
snmp  161/udp    # Simple Net Mgmt Proto
snmp-trap 162/udp  snmptrap # Traps for SNMP
cmip-man 163/tcp    # ISO mgmt over IP (CMOT)
cmip-man 163/udp
cmip-agent 164/tcp
cmip-agent 164/udp
xdmcp  177/tcp    # X Display Mgr. Control Proto
xdmcp  177/udp
nextstep 178/tcp  NeXTStep NextStep # NeXTStep window
nextstep 178/udp  NeXTStep NextStep # server
bgp  179/tcp    # Border Gateway Proto.
bgp  179/udp
prospero 191/tcp    # Cliff Neuman's Prospero
prospero 191/udp
irc  194/tcp    # Internet Relay Chat
irc  194/udp
smux  199/tcp    # SNMP Unix Multiplexer
smux  199/udp
at-rtmp  201/tcp    # AppleTalk routing
at-rtmp  201/udp
at-nbp  202/tcp    # AppleTalk name binding
at-nbp  202/udp
at-echo  204/tcp    # AppleTalk echo
at-echo  204/udp
at-zis  206/tcp    # AppleTalk zone information
at-zis  206/udp
qmtp  209/tcp    # The Quick Mail Transfer Protocol
qmtp  209/udp    # The Quick Mail Transfer Protocol
z3950  210/tcp  wais  # NISO Z39.50 database
z3950  210/udp  wais
ipx  213/tcp    # IPX
ipx  213/udp
imap3  220/tcp    # Interactive Mail Access
imap3  220/udp    # Protocol v3
ulistserv 372/tcp    # UNIX Listserv
ulistserv 372/udp
https  443/tcp    # MCom
https  443/udp    # MCom
snpp  444/tcp    # Simple Network Paging Protocol
snpp  444/udp    # Simple Network Paging Protocol
saft  487/tcp    # Simple Asynchronous File Transfer
saft  487/udp    # Simple Asynchronous File Transfer
npmp-local 610/tcp  dqs313_qmaster # npmp-local / DQS
npmp-local 610/udp  dqs313_qmaster # npmp-local / DQS
npmp-gui 611/tcp  dqs313_execd # npmp-gui / DQS
npmp-gui 611/udp  dqs313_execd # npmp-gui / DQS
hmmp-ind 612/tcp  dqs313_intercell# HMMP Indication / DQS
hmmp-ind 612/udp  dqs313_intercell# HMMP Indication / DQS
#
# UNIX specific services
#
exec  512/tcp
biff  512/udp  comsat
login  513/tcp
who  513/udp  whod
shell  514/tcp  cmd  # no passwords used
syslog  514/udp
printer  515/tcp  spooler  # line printer spooler
talk  517/udp
ntalk  518/udp
route  520/udp  router routed # RIP
timed  525/udp  timeserver
tempo  526/tcp  newdate
courier  530/tcp  rpc
conference 531/tcp  chat
netnews  532/tcp  readnews
netwall  533/udp    # -for emergency broadcasts
uucp  540/tcp  uucpd  # uucp daemon
afpovertcp 548/tcp    # AFP over TCP
afpovertcp 548/udp    # AFP over TCP
remotefs 556/tcp  rfs_server rfs # Brunhoff remote filesystem
klogin  543/tcp    # Kerberized `rlogin' (v5)
kshell  544/tcp  krcmd  # Kerberized `rsh' (v5)
kerberos-adm 749/tcp    # Kerberos `kadmin' (v5)
#
webster  765/tcp    # Network dictionary
webster  765/udp
#
# From ``Assigned Numbers'':
#
#> The Registered Ports are not controlled by the IANA and on most systems
#> can be used by ordinary user processes or programs executed by ordinary
#> users.
#
#> Ports are used in the TCP [45,106] to name the ends of logical
#> connections which carry long term conversations.  For the purpose of
#> providing services to unknown callers, a service contact port is
#> defined.  This list specifies the port used by the server process as its
#> contact port.  While the IANA can not control uses of these ports it
#> does register or list uses of these ports as a convienence to the
#> community.
#
nfsdstatus 1110/tcp
nfsd-keepalive 1110/udp

ingreslock 1524/tcp
ingreslock 1524/udp
prospero-np 1525/tcp   # Prospero non-privileged
prospero-np 1525/udp
datametrics 1645/tcp old-radius # datametrics / old radius entry
datametrics 1645/udp old-radius # datametrics / old radius entry
sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry
sa-msg-port 1646/udp old-radacct # sa-msg-port / old radacct entry
radius  1812/tcp   # Radius
radius  1812/udp   # Radius
radacct  1813/tcp   # Radius Accounting
radacct  1813/udp   # Radius Accounting
nfsd  2049/tcp nfs
nfsd  2049/udp nfs
cvspserver 2401/tcp   # CVS client/server operations
cvspserver 2401/udp   # CVS client/server operations
mysql  3306/tcp   # MySQL
mysql  3306/udp   # MySQL
rfe  5002/tcp   # Radio Free Ethernet
rfe  5002/udp   # Actually uses UDP only
cfengine 5308/tcp   # CFengine
cfengine 5308/udp   # CFengine
bbs  7000/tcp   # BBS service
#
#
# Kerberos (Project Athena/MIT) services
# Note that these are for Kerberos v4, and are unofficial.  Sites running
# v4 should uncomment these and comment out the v5 entries above.
#
kerberos4 750/udp  kerberos-iv kdc # Kerberos (server) udp
kerberos4 750/tcp  kerberos-iv kdc # Kerberos (server) tcp
kerberos_master 751/udp    # Kerberos authentication
kerberos_master 751/tcp    # Kerberos authentication
passwd_server 752/udp    # Kerberos passwd server
krb_prop 754/tcp    # Kerberos slave propagation
krbupdate 760/tcp  kreg  # Kerberos registration
kpasswd  761/tcp  kpwd  # Kerberos "passwd"
kpop  1109/tcp   # Pop with Kerberos
knetd  2053/tcp   # Kerberos de-multiplexor
zephyr-srv 2102/udp   # Zephyr server
zephyr-clt 2103/udp   # Zephyr serv-hm connection
zephyr-hm 2104/udp   # Zephyr hostmanager
eklogin  2105/tcp   # Kerberos encrypted rlogin
#
# Unofficial but necessary (for NetBSD) services
#
supfilesrv 871/tcp    # SUP server
supfiledbg 1127/tcp   # SUP debugging
#
# Datagram Delivery Protocol services
#
rtmp  1/ddp    # Routing Table Maintenance Protocol
nbp  2/ddp    # Name Binding Protocol
echo  4/ddp    # AppleTalk Echo Protocol
zip  6/ddp    # Zone Information Protocol
#
# Services added for the Debian GNU/Linux distribution
poppassd 106/tcp    # Eudora
poppassd 106/udp    # Eudora
mailq  174/tcp    # Mailer transport queue for Zmailer
mailq  174/tcp    # Mailer transport queue for Zmailer
omirr  808/tcp  omirrd  # online mirror
omirr  808/udp  omirrd  # online mirror
rmtcfg  1236/tcp   # Gracilis Packeten remote config server
xtel  1313/tcp   # french minitel
coda_opcons 1355/udp   # Coda opcons            (Coda fs)
coda_venus 1363/udp   # Coda venus             (Coda fs)
coda_auth 1357/udp   # Coda auth              (Coda fs)
coda_udpsrv 1359/udp   # Coda udpsrv            (Coda fs)
coda_filesrv 1361/udp   # Coda filesrv           (Coda fs)
codacon  1423/tcp venus.cmu # Coda Console           (Coda fs)
coda_aux1 1431/tcp   # coda auxiliary service (Coda fs)
coda_aux1 1431/udp   # coda auxiliary service (Coda fs)
coda_aux2 1433/tcp   # coda auxiliary service (Coda fs)
coda_aux2 1433/udp   # coda auxiliary service (Coda fs)
coda_aux3 1435/tcp   # coda auxiliary service (Coda fs)
coda_aux3 1435/udp   # coda auxiliary service (Coda fs)
cfinger  2003/tcp   # GNU Finger
afbackup 2988/tcp   # Afbackup system
afbackup 2988/udp   # Afbackup system
icp  3130/tcp   # Internet Cache Protocol (Squid)
icp  3130/udp   # Internet Cache Protocol (Squid)
postgres 5432/tcp   # POSTGRES
postgres 5432/udp   # POSTGRES
fax  4557/tcp   # FAX transmission service        (old)
hylafax  4559/tcp   # HylaFAX client-server protocol  (new)
noclog  5354/tcp   # noclogd with TCP (nocol)
noclog  5354/udp   # noclogd with UDP (nocol)
hostmon  5355/tcp   # hostmon uses TCP (nocol)
hostmon  5355/udp   # hostmon uses TCP (nocol)
ircd  6667/tcp   # Internet Relay Chat
ircd  6667/udp   # Internet Relay Chat
webcache 8080/tcp   # WWW caching service
webcache 8080/udp   # WWW caching service
tproxy  8081/tcp   # Transparent Proxy
tproxy  8081/udp   # Transparent Proxy
mandelspawn 9359/udp mandelbrot # network mandelbrot
amanda  10080/udp   # amanda backup services
amandaidx 10082/tcp   # amanda backup services
amidxtape 10083/tcp   # amanda backup services
isdnlog  20011/tcp   # isdn logging system
isdnlog  20011/udp   # isdn logging system
vboxd  20012/tcp   # voice box system
vboxd  20012/udp   # voice box system
binkp           24554/tcp   # Binkley
binkp           24554/udp   # Binkley
asp  27374/tcp   # Address Search Protocol
asp  27374/udp   # Address Search Protocol
tfido           60177/tcp   # Ifmail
tfido           60177/udp   # Ifmail
fido            60179/tcp   # Ifmail
fido            60179/udp   # Ifmail

# Local services
smb.conf
[global]
server string      =  FLKNAS
workgroup          =  SEAGATEGROUP
log file           =  /private/%L.log
max log size       =  1024
security           =  share
smb passwd file    =  /private/smbpasswd
private dir        =  /private
dns proxy          =  No
lock directory     =  /private/locks
pid directory      =  /private/locks
client lanman auth =  yes
use sendfile       =  yes
vfs objects        =  streams_xattr

[tmp]
path=/tmp
read only=no
public=yes
Porting Server
build_ntfs-3g.sh
#!/bin/sh

. ./scripts/build_subr.sh

rm -rf ${INSTALLDIR}
mkdir -p ${INSTALLDIR}
unpack "ntfs-3g-2009.4.4"
SRC="build/ntfs-3g-2009.4.4"

cd ${TOPDIR}/${SRC}

export  LD_LIBARY_PATH=${CROSS_COMPILE}/lib
export  CPPFLAGS=-I${CROSS_COMPILE}/include
export  LDFLAGS=-L${CROSS_COMPILE}/lib
export  CC=${CROSS_COMPILE}-gcc
export  PATH=${PATH}:${TOPDIR}/tools/gcc/bin

./configure --host=arm-linux --prefix=${INSTALLDIR} --exec-prefix=${INSTALLDIR}

make
check_errno

make install
check_errno

cd ${INSTALLDIR}/..

tar -jc -f ${TOPDIR}/pkg/softfp/ntfs-3g-2009.4.4.full-bin.tar.bz2 ${ROOTFS}
check_errno

mv ${INSTALLDIR}/share ${INSTALLDIR}/share.qq
rm -rf ${INSTALLDIR}/share.qq 

#rm -f ${INSTALLDIR}/bin/ntfs-3g.probe

mv ${INSTALLDIR}/lib/pkgconfig ${INSTALLDIR}/lib/pkgconfig.qq
rm -rf ${INSTALLDIR}/lib/pkgconfig.qq

mv ${INSTALLDIR}/include ${INSTALLDIR}/include.qq
rm -rf ${INSTALLDIR}/include.qq

mv ${INSTALLDIR}/sbin ${INSTALLDIR}/sbin.qq
rm -rf ${INSTALLDIR}/sbin.qq 

tar -jc -f ${TOPDIR}/pkg/softfp/ntfs-3g-2009.4.4-bin.tar.bz2 ${ROOTFS} 
check_errno

mv ${TOPDIR}/build ${TOPDIR}/build.qq
mkdir -p ${TOPDIR}/build
rm -rf ${TOPDIR}/build.qq &

mv ${TOPDIR}/tmp ${TOPDIR}/tmp.qq
mkdir -p ${TOPDIR}/tmp
rm -rf ${TOPDIR}/tmp.qq &   

cd ${TOPDIR}
build_samba.sh
#!/bin/sh

. ./scripts/build_subr.sh

rm -rf ${INSTALLDIR}
mkdir -p ${INSTALLDIR}
unpack "samba-3.3.4"
SRC="build/samba-3.3.4/source"

cp -f ${TOPDIR}/patch/samba-3.3.4/configure.patch ${TOPDIR}/${SRC}
cp -f ${TOPDIR}/patch/samba-3.3.4/mtab.c.patch ${TOPDIR}/${SRC}/client

cd ${TOPDIR}/${SRC}
patch -p0 < configure.patch

cd ${TOPDIR}/${SRC}/client
patch -p0 < mtab.c.patch

cd ..

export  LD_LIBARY_PATH=${CROSS_COMPILE}/lib
export  CPPFLAGS=-I${CROSS_COMPILE}/include
export  LDFLAGS=-L${CROSS_COMPILE}/lib
export  CC=${CROSS_COMPILE}-gcc
export  PATH=${PATH}:${TOPDIR}/tools/gcc/bin

export samba_cv_CC_NEGATIVE_ENUM_VALUES=yes
export libreplace_cv_READDIR_GETDIRENTRIES=no
export libreplace_cv_READDIR_GETDENTS=no
export linux_getgrouplist_ok=no
export samba_cv_HAVE_WRFILE_KEYTAB=yes
export samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes
export samba_cv_HAVE_IFACE_IFCONF=yes

./configure --build=i686-linux --host=arm-linux --target=arm-linux --prefix=${INSTALLDIR} --disable-shared --disable-cups --disable-iprint --disable-pie --disable-fam --without-ldap

cp -f ${TOPDIR}/patch/samba-3.3.4/config.h ${TOPDIR}/${SRC}/include

make
check_errno

make install
check_errno

cd ${INSTALLDIR}/..

tar -jc -f ${TOPDIR}/pkg/softfp/samba-3.3.4.full-bin.tar.bz2 ${ROOTFS} 
check_errno

mv ${INSTALLDIR}/swat ${INSTALLDIR}/swat.qq
rm -rf ${INSTALLDIR}/swat.qq

mv ${INSTALLDIR}/share ${INSTALLDIR}/share.qq
rm -rf ${INSTALLDIR}/share.qq 

rm -f ${INSTALLDIR}/sbin/mount.cifs
rm -f ${INSTALLDIR}/sbin/swat
rm -f ${INSTALLDIR}/sbin/umount.cifs
rm -f ${INSTALLDIR}/sbin/winbindd

mv ${INSTALLDIR}/lib ${INSTALLDIR}/lib.qq
rm -rf ${INSTALLDIR}/lib.qq

mv ${INSTALLDIR}/include ${INSTALLDIR}/include.qq
rm -rf ${INSTALLDIR}/include.qq

mv ${INSTALLDIR}/bin ${INSTALLDIR}/bin.qq
rm -rf ${INSTALLDIR}/bin.qq 

tar -jc -f ${TOPDIR}/pkg/softfp/samba-3.3.4-bin.tar.bz2 ${ROOTFS} 
check_errno

mv ${TOPDIR}/build ${TOPDIR}/build.qq
mkdir -p ${TOPDIR}/build
rm -rf ${TOPDIR}/build.qq &

mv ${TOPDIR}/tmp ${TOPDIR}/tmp.qq
mkdir -p ${TOPDIR}/tmp
rm -rf ${TOPDIR}/tmp.qq &   

cd ${TOPDIR}
configure.patch
--- configure 2009-04-29 02:53:51.000000000 +0800
+++ configure.new 2009-05-05 16:23:23.000000000 +0800
@@ -13066,13 +13066,17 @@
 else
 
     if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: uclibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: uclibc <= samba 3.3.4 check skipped" >&2;
+}
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -23586,12 +23590,12 @@
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
+   builtin and then its argument prototype would st cannot run test program while cross compilingill apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 char $ac_func ();
-/* The GNU C library defines this for functions which it implements
+/* The GNU C library defines this for functions whi cannot run test program while cross compilingch it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined __stub_$ac_func || defined __stub___$ac_func
@@ -23801,13 +23805,17 @@
 else
 
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -23989,13 +23997,17 @@
 else
 
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -44068,13 +44080,17 @@
     *linux*)
        # glibc <= 2.3.2 has a broken getgrouplist
        if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -67118,13 +67134,17 @@
 else
 
     if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -67393,13 +67413,17 @@
  LDFLAGS="$LDFLAGS";
  export LDFLAGS;
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -67494,13 +67518,17 @@
  LDFLAGS="$LDFLAGS";
  export LDFLAGS;
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
mtab.c.patch
--- mtab.c 2009-04-28 14:46:16.000000000 +0800
+++ mtab.c.new 2009-05-05 16:25:33.000000000 +0800
@@ -34,6 +34,8 @@
 #include <sys/time.h>
 #include <time.h>
 #include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <mntent.h>
 #include <stdlib.h>
 #include <signal.h>
Application
netlink_udev.c
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <ctype.h> 
#include <sys/un.h> 
#include <sys/ioctl.h> 
#include <sys/socket.h> 
#include <linux/types.h> 
#include <linux/netlink.h> 
#include <errno.h> 
#include <unistd.h> 
#include <arpa/inet.h> 
#include <netinet/in.h> 

#define UEVENT_BUFFER_SIZE 2048 

static int init_hotplug_sock() 
{ 
    const int buffersize = 1024; 
    int ret; 

    struct sockaddr_nl snl; 
    bzero(&snl, sizeof(struct sockaddr_nl)); 
    snl.nl_family = AF_NETLINK; 
    snl.nl_pid = getpid(); 
    snl.nl_groups = 1; 

    int s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); 
    if (s == -1)  
    { 
        perror("socket"); 
        return -1; 
    } 
    setsockopt(s, SOL_SOCKET, SO_RCVBUF, &buffersize, sizeof(buffersize)); 

    ret = bind(s, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)); 
    if (ret < 0)  
    { 
        perror("bind"); 
        close(s); 
        return -1; 
    } 

    return s; 
} 

int main(int argc, char* argv[]) 
{ 
   int hotplug_sock = init_hotplug_sock(); 
  
    while(1) 
    { 
      /* Netlink message buffer */ 
        char buf[UEVENT_BUFFER_SIZE * 2] = {0}; 
        recv(hotplug_sock, &buf, sizeof(buf), 0); 
        printf("%s\n", buf); 
    } 
    return 0; 
}
scsi_serial.c
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/sg.h>

#define SCSI_TIMEOUT 5000 /* ms */

static char *device  = "/dev/sdd";

int scsi_io(int fd, unsigned char *cdb, unsigned char cdb_size, int xfer_dir, 
            unsigned char *data, unsigned int *data_size, 
            unsigned char *sense, unsigned int *sense_len)
{
    sg_io_hdr_t io_hdr;

    memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
    io_hdr.interface_id = 'S';

    /* CDB */
    io_hdr.cmdp = cdb;
    io_hdr.cmd_len = cdb_size;

    /* Where to store the sense_data, if there was an error */
    io_hdr.sbp = sense;
    io_hdr.mx_sb_len = *sense_len;
    *sense_len=0;

    /* Transfer direction, either in or out. Linux does not yet
       support bidirectional SCSI transfers ?
     */
    io_hdr.dxfer_direction = xfer_dir;

    /* Where to store the DATA IN/OUT from the device and how big the
       buffer is
     */
    io_hdr.dxferp = data;
    io_hdr.dxfer_len = *data_size;

    /* SCSI timeout in ms */
    io_hdr.timeout = SCSI_TIMEOUT;

    if(ioctl(fd, SG_IO, &io_hdr) < 0){
        perror("SG_IO ioctl failed");
        return -1;
    }

    /* now for the error processing */
    if((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK){
        if(io_hdr.sb_len_wr > 0){
            *sense_len=io_hdr.sb_len_wr;
            return 0;
        }
    }
    if(io_hdr.masked_status){
        printf("status=0x%x\n", io_hdr.status);
        printf("masked_status=0x%x\n", io_hdr.masked_status);
        return -2;
    }
    if(io_hdr.host_status){
        printf("host_status=0x%x\n", io_hdr.host_status);
        return -3;
    }
    if(io_hdr.driver_status){
        printf("driver_status=0x%x\n", io_hdr.driver_status);
        return -4;
    }
    return 0;
}

int scsi_inquiry_unit_serial_number(int fd)
{
    unsigned char cdb[]={0x12,0x01,0x80,0,0,0};

    unsigned int data_size=0x00ff;
    unsigned char data[data_size];

    unsigned int sense_len=32;
    unsigned char sense[sense_len];

    int res, pl, i;

    cdb[3]=(data_size>>8)&0xff;
    cdb[4]=data_size&0xff;


    printf("INQUIRY Unit Serial Number:\n");

    res=scsi_io(fd, cdb, sizeof(cdb), SG_DXFER_FROM_DEV, data, &data_size, sense, &sense_len);
    if(res){
        printf("SCSI_IO failed\n");
        return -1;
    }
    if(sense_len){
        return -1;
    }

    /* Page Length */
    pl=data[3];

    /* Unit Serial Number */
    printf("Unit Serial Number:");
    for(i=4;i<(pl+4);i++)printf("%c",data[i]&0xff);printf("\n");
    return 0;
}

int open_scsi_device(const char *dev)
{
    int fd, vers;

    if((fd=open(dev, O_RDWR))<0){
        printf("ERROR could not open device %s\n", dev);
        return -1;
    }
    if ((ioctl(fd, SG_GET_VERSION_NUM, &vers) < 0) || (vers < 30000)) {
        printf("/dev is not an sg device, or old sg driver\n");
        close(fd);
        return -1;
    }

    return fd;
}

int main(int argc, const char *argv[])
{
    int fd;

    fd=open_scsi_device(device);
    if(fd<0){
        printf("Could not open SCSI device %s\n",device);
        _exit(10);
    }

    scsi_inquiry_unit_serial_number(fd);
    return 0;
}
FSinotify.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/file.h>
#include <sys/sysinfo.h>
#include <sys/epoll.h>
#include <signal.h>
#include <linux/inotify.h>
#include <net/if.h>
#include <netinet/in.h>
 
struct queue_struct
{
    int capacity;
    int front;
    int rear;
    int size;
    void **array;
};
 
struct queue_struct;
typedef struct queue_struct *queue_t;
 
int queue_empty (queue_t q)
{
    return q->size == 0;
}
 
int queue_full (queue_t q)
{
    return q->size == q->capacity;
}


void queue_make_empty (queue_t q)
{
    q->size = 0;
    q->front = 1;
    q->rear = 0;
}
 
queue_t queue_create (int num_elements)
{
    queue_t q;
 
    q = malloc (sizeof (struct queue_struct));
 
    if (q == NULL)
        exit (-1);
 
    q->array = malloc(sizeof (void *) * num_elements);
 
    if (q->array == NULL)
        exit (-1);
 
    q->capacity = num_elements;
 
    queue_make_empty (q);
 
    return q;
}
 
void queue_destroy (queue_t q)
{
    if (q != NULL)
    {
        if (q->array)
            free (q->array);
 
        free (q);
    }
}
 
 
static int next_position (int v, queue_t q)
{
    if (++v == q->capacity) {
        v = 0;
    }
 
    return v;
}
 
void queue_enqueue (void *d, queue_t q)
{
    if (queue_full (q))
    {
        return;
    }
 
    q->size++;
    q->rear = next_position (q->rear, q);
    q->array[q->rear] = d;
}
 
void *queue_front (queue_t q)
{
    if (!queue_empty(q))
        return q->array [q->front];
 
    return NULL;
}
 
void queue_dequeue (queue_t q)
{
    if (!queue_empty (q))
    {
        q->size--;
        q->front = next_position (q->front, q);
    }
}
 
/* This method does the dirty work of determining what happened,
then allows us to act appropriately
*/
void handle_event (struct inotify_event *event)
{
    /* If the event was associated with a filename, we will store it here */
    char * cur_event_filename = NULL;
    /* This is the watch descriptor the event occurred on */
    int cur_event_wd = event->wd;
    if (event->len)
    {
        cur_event_filename = event->name;
    }
    printf("FILENAME=%s\n", cur_event_filename);
    printf("watch descriptor=%d\n",cur_event_wd);
    printf("\n");
    /* Perform event dependent handler routines */
    /* The mask is the magic that tells us what file operation occurred */
    switch (event->mask)
    {
    /* File was accessed */
    case IN_ACCESS:
        printf("ACCESS EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File was modified */
    case IN_MODIFY:
        printf("MODIFY EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File changed attributes */
    case IN_ATTRIB:
        printf("ATTRIB EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File was closed */
    case IN_CLOSE:
        printf("CLOSE EVENT OCCURRED: File \"%s\" on WD #%i\n",
    cur_event_filename, cur_event_wd);
    break;
    /* File was opened */
    case IN_OPEN:
    printf("OPEN EVENT OCCURRED: File \"%s\" on WD #%i\n",
    cur_event_filename, cur_event_wd);
    break;
    /* File was moved from X */
    case IN_MOVED_FROM:
        printf("MOVE_FROM EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File was moved to X */
    case IN_MOVED_TO:
        printf("MOVE_TO EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* Watched entry was deleted */
    case IN_DELETE_SELF:
        printf("DELETE_SELF EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* Backing FS was unmounted */
    case IN_UNMOUNT:
        printf("UNMOUNT EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* Too many FS events were received without reading them
    some event notifications were potentially lost. */
    case IN_Q_OVERFLOW:
        printf("Warning: AN OVERFLOW EVENT OCCURRED: \n");
        break;
    case IN_IGNORED:
        printf("IGNORED EVENT OCCURRED: \n");
    break;
    /* Some unknown message received */
    default:
    printf ("UNKNOWN EVENT OCCURRED for file \"%s\" on WD #%i\n",
    cur_event_filename, cur_event_wd);
    break;
    }
}
 
void handle_events (queue_t q)
{
    struct inotify_event *event;
    while (!queue_empty (q))
    {
        event = queue_front (q);
        queue_dequeue (q);
        handle_event (event);
        free (event);
    }
}
 
int event_check (int fd)
{
    struct timeval timeout;
    int r;
    fd_set rfds;
 
    timeout.tv_sec = 4;
    timeout.tv_usec = 0;
 
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
 
    r = select (fd+1, &rfds, NULL, NULL, &timeout);
 
    return r;
}
 
int read_events (queue_t q, int fd)
{
    char buffer[16384];
    size_t buffer_i;
    struct inotify_event *pevent, *event;
    ssize_t r;
    size_t event_size;
    int count = 0;
 
    r = read (fd, buffer, 16384);
 
    if (r <= 0)
        return r;
 
    buffer_i = 0;
    while (buffer_i < r)
    {
        /* Parse events and queue them ! */
        pevent = (struct inotify_event *)&buffer[buffer_i];
        event_size = sizeof(struct inotify_event) + pevent->len;
        event = malloc(event_size);
        memmove(event, pevent, event_size);
        queue_enqueue(event, q);
        buffer_i += event_size;
        count++;
    }
 
    return count;
}
 
int process_inotify_events (queue_t q, int iid)
{
    while (1)
    {
        if( !queue_empty(q) )
        {
            handle_events(q);
        }
        if (event_check(iid) > 0)
        {
            int r;
            r = read_events(q, iid);
            if (r < 0)
                break;
        }
    }
    return 0;
}
 
int main()
{
    queue_t q;
    int     iid;
    int     wd;
    
    q    = queue_create(128);
    iid = inotify_init(); 
    wd   = inotify_add_watch(iid,"/home/test/", IN_CLOSE_WRITE );
    process_inotify_events(q,iid);
  
    queue_destroy(q);
    close(iid);
    return 0;
}




主要工作小結
1. 架設版本控制平台 SVN
2. 專案版本控制管理

3. 專案開發環境架設 fedora8及其BSP環境

4. 管理與整合BSP

5.  build imagerelease版本

6. 應用程式開發



心得

1. 更熟析embedded linux
2. 熟西建構root file system
3. 對linux system programming有一定的了解





[轉]linux 下视频设备设置的几个参数 v4l video4linux v4l2 ioctl

用一系列的ioctl发命令控制设备。v4l支持的ioctl命令大概有二十几个,为了尽快的编出一个
简单的图象捕捉程序,让我们先来看看几个主要的命令:



1. ioctl(fd,VIDIOCGCAP,&cap);
   该命令主要是为了获取电视卡的功能信息。例如电视卡的名称,类型,channel等。参数cap是一个结构,当ioctl命令返回时,结构的各成员就被赋值了,结构体的定义为:
struct video_capability
{
        char name[32];
        int type;
        int channels;        /* Num channels */
        int audios;        /* Num audio devices */
        int maxwidth;        /* Supported width */
        int maxheight;        /* And height */
        int minwidth;        /* Supported width */
        int minheight;        /* And height */
};
channel 指的是有几个信号输入源,例如television,composite,s-video等。

2.ioctl(fd,VIDIOCGCHAN,&vc)
3.ioctl(fd,VIDIOCSCHAN.&vc)
这两个命令用来取得和设置电视卡的channel信息,例如使用那个输入源,制式等。
vc 是一个video_channel结构,其定义为:
struct video_capability
{
        char name[32];
        int type;
        int channels;        /* Num channels */
        int audios;        /* Num audio devices */
        int maxwidth;        /* Supported width */
        int maxheight;        /* And height */
        int minwidth;        /* Supported width */
        int minheight;        /* And height */
};


struct video_channel
{
        int channel;
        char name[32];
        int tuners;//number of tuners for this input
        __u32  flags;
        __u16  type;        
        __u16 norm;                
};
成员channel代表输入源,通常,0: television 1:composite1 2:s-video
name 表示该输入源的名称。
norm 表示制式,通常,0:pal 1:ntsc 2:secam 3:auto

4. ioctl(fd,VIDIOCGMBUF,*mbuf)
获得电视卡缓存的信息,参数mbuf是video_mbuf结构。其定义如下:
struct video_mbuf
{
        int        size;                /* Total memory to map */
        int        frames;                /* Frames */
        int        offsets[VIDEO_MAX_FRAME];
};
size是缓存的大小,frames表明该电视卡的缓存可以容纳的帧数,数组offsets则表明
对应一帧的起始位置,0帧对应offsets[0],1帧对应offsets[1]....
执行完该命令后,就可以用mmap函数将缓存映射到内存中了。大致用法可以参考以下的代
struct video_mbuf mbuf;
unsigned char *buf1,*buf2;

if(ioctl(fd,VIDIOCGMBUF,&mbuf)<0)
{
        perror("VIDIOCGMBUF");
        return -1;
}

printf("the frame number is %d\n",mbuf.frames);

buf1 = (unsigned char*)mmap(0,mbuf.size,PROT_READ|PROT_WRITE,MAP_SHARED,fd.0);

buf1 = buf1 + mbuf.offset[0];
buf2 = buf1 + mbuf.offset[1];//当然,如果mbuf.frames=1,就不需要下面的了。
......

5. ioctl(fd.VIDIOCMCAPTURE,&mm)
   启动硬件去捕捉图象,mm 是video_mmap 结构,设置捕捉图象需要设置的信息。结构体
如下定义:

struct video_mmap
{
        unsigned        int frame;                /* Frame (0 - n) for double buffer */
        int                height,width;
        unsigned        int format;                /* should be VIDEO_PALETTE_* */
};
frame :设置当前是第几帧
height,width:设置图象的高和宽。
format :颜色模式

要注意的是,该命令是非阻塞的,也就是说,它仅仅设置了硬件,而不负责是否捕捉到图象。
要确定是否捕捉到图象,要用到下一个命令。

6. ioctl(fd,VIDIOCSYNC,&frame)
等待捕捉到这一帧图象。frame 是要等待的图象,它的值应和上一个命令中设置的frame相对应。

好了,说了这么多,读者大概也对视频捕捉有了一个了解,是不是想亲自动手试一下,那就让我们
开始实际程序的编写吧。
下面我们会编一个程序,将捕捉到的图象存为jpeg文件。为此,还要向大家介绍一个函数,

int write_jpeg(char *filename,unsigned char *buf,int quality,int width, int height, int gray)
{
    struct jpeg_compress_struct cinfo;
    struct jpeg_error_mgr jerr;
    FILE *fp;
    int i;
    unsigned char *line;
    int line_length;
    
    if (NULL == (fp = fopen(filename,"w"))) 
    {
                fprintf(stderr,"grab: can't open %s: %s\n",filename,strerror(errno));
                return -1;
    }
    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_compress(&cinfo);
    jpeg_stdio_dest(&cinfo, fp);
    cinfo.image_width  = width;
    cinfo.image_height = height;
    cinfo.input_components = gray ? 1: 3;
    cinfo.in_color_space = gray ? JCS_GRAYSCALE: JCS_RGB;
    jpeg_set_defaults(&cinfo);
    jpeg_set_quality(&cinfo, quality, TRUE);
    jpeg_start_compress(&cinfo, TRUE);

    line_length = gray ? width : width * 3;
    for (i = 0, line = buf; i < height; i++, line += line_length)
        jpeg_write_scanlines(&cinfo, &line, 1);
    
    jpeg_finish_compress(&(cinfo));
    jpeg_destroy_compress(&(cinfo));
    fclose(fp);

    return 0;
}

这个函数很通用,它的作用是把buf中的数据压缩成jpeg格式。

/*         下面是一个完整的程序 test.c
*           gcc test.c -o test -ljpeg
*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <errno.h>
#include <linux/videodev.h>
         
#include <jpeglib.h>

#define WIDTH  320
#define HEIGHT 240
#define V4L_DEVICE "/dev/video0"

main()
{

   unsigned char* buf;
   int i,j;
   int fd;
   int re;

   struct video_capability vcap;
   struct video_channel    vc;
   struct video_mbuf       mbuf;
   struct video_mmap       mm;

   fd = open(V4L_DEVICE, O_RDWR);
   if(fd<=0)
   {
           perror("open");
             exit(1);
   }

   if(ioctl(fd, VIDIOCGCAP, &vcap)<0)
   {
             perror("VIDIOCGCAP");
             exit(1);
   }

   fprintf(stderr,"Video Capture Device Name : %s\n",vcap.name);

   for(i=0;i<vcap.channels;i++)
   {
             vc.channel = i;
             if(ioctl(fd, VIDIOCGCHAN, &vc)<0)
             {
                       perror("VIDIOCGCHAN");
                       exit(1);
             }

             fprintf(stderr,"Video Source (%d) Name : %s\n",i, vc.name);
   }

   vc.channel =1;
   vc.norm=1;

   if(ioctl(fd, VIDIOCSCHAN, &vc) < 0)
   {
             perror("VIDIOCSCHAN");
             exit(1);
   }

  if(ioctl(fd, VIDIOCGMBUF, &mbuf) < 0)
  {
        perror("VIDIOCGMBUF");
        exit(1);
  }
   fprintf(stderr,"the frames number is %d\n",mbuf.frames); 

  buf = (unsigned char*)mmap(0, mbuf.size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
   if((int)buf < 0)
   {
             perror("mmap");
             exit(1);
   }
   mm.frame  = 0;
   mm.height = HEIGHT;
   mm.width  = WIDTH;
   mm.format = VIDEO_PALETTE_RGB24;

   if(ioctl(fd, VIDIOCMCAPTURE, &mm)<0)
   {
             perror("VIDIOCMCAPTURE");
            exit(1);
   }

   if(ioctl(fd, VIDIOCSYNC, &mm.frame)<0)
   {
             perror("VIDIOCSYNC");
             exit(1);
   }

if(-1 == (write_jpeg("./pic001.jpeg",buf,75,WIDTH,HEIGHT,0)))
{
        printf("write_jpeg error\n");
        exit(1);
}

   munmap(buf,mbuf.size);
   close(fd);
}


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lanmanck/archive/2009/04/13/4069534.aspx

Porting CMOS Sensor OV9650 form 2.6.24 to android kernel 2.6.29 on dma6410xp

由於dma6410xp的camera還不能動,
所以要了一份 kernel 2.6.24的OV9650 driver,
參考s5k4ba修改ov9650

基本上ov9650 透過 I2C 連到 s3c6410 camera control上
























ov9650.c
#include <linux/autoconf.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/i2c-id.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/delay.h>

//#define CAMIF_DEBUG

#include "s3c_camif.h"
#include "ov9650.h"

static const char *sensor_version = "ov9650.c 2010/11/6";

static void delay(int i)
{
 int j;
 for(j=0;j<i*10;j++);
}

static struct i2c_driver ov9650_driver;

/* This is SXGA(1280x1024) camera but start from VGA(640x480) mode */
static camif_cis_t ov9650_data = 
{
        itu_fmt:       CAMIF_ITU601,
        order422:      CAMIF_YCBYCR,  //YCRYCB
        camclk:        24000000, /* No effect */
        source_x:      640,
        source_y:      480,
        win_hor_ofst:  0,
        win_ver_ofst:  0,
        win_hor_ofst2: 0,
        win_ver_ofst2: 0,
        polarity_pclk: 1,
        polarity_vsync:1,
        polarity_href: 0,        
        reset_type:CAMIF_EX_RESET_AL, /* Active Low */
        reset_udelay: 20000,
};

ov9650_t ov9650_regs_mirror[OV9650_REGS];

extern camif_cis_t* get_initialized_cis(void);
camif_cis_t* get_initialized_cis() 
{
        printk(KERN_CRIT"[CAM DRV]+get_initialized_cis\n");
        if(ov9650_data.init_sensor == 0) return NULL;
        printk(KERN_CRIT"[CAM DRV]-get_initialized_cis\n");
        return &ov9650_data;
}

//the device slave address are 60 for read 61 for write
#define CAM_ID 0x60

static unsigned short ignore[] = { I2C_CLIENT_END };
static unsigned short normal_addr[] = { (CAM_ID >> 1), I2C_CLIENT_END };

static struct i2c_client_address_data addr_data = 
{
      normal_i2c:normal_addr,
      probe:ignore,
      ignore:ignore,
};


unsigned char sensor_read(struct i2c_client *client, unsigned char subaddr)
{
        int ret;
        unsigned char buf[1];
        struct i2c_msg msg = { client->addr, 0, 1, buf };
        buf[0] = subaddr;

        printk(KERN_CRIT"[CAM DRV]+sensor_read\n");
        ret = i2c_transfer(client->adapter, &msg, 1) == 1 ? 0 : -EIO;
        if (ret == -EIO) {
            printk(" I2C write Error \n");
            return -EIO;
        }

        msg.flags = I2C_M_RD;
        ret = i2c_transfer(client->adapter, &msg, 1) == 1 ? 0 : -EIO;

        printk(KERN_CRIT"[CAM DRV]-sensor_read\n");
        return buf[0];
}


static int sensor_write(struct i2c_client *client,
             unsigned char subaddr, unsigned char val)
{
        unsigned char buf[2];
        struct i2c_msg msg = { client->addr, 0, 2, buf };

        printk(KERN_CRIT"[CAM DRV]+sensor_write\n");
        buf[0] = subaddr;
        buf[1] = val;

        printk(KERN_CRIT"[CAM DRV]-sensor_write\n");
        return i2c_transfer(client->adapter, &msg, 1) == 1 ? 0 : -EIO;
}

void inline sensor_testreg(struct i2c_client *sam_client)
{
 ov9650_t testreg[OV9650_INIT_REGS];
 int i;
        printk(KERN_CRIT"[CAM DRV]+sensor_testreg\n");
 for (i = 0; i < OV9650_INIT_REGS; i++) {
  testreg[i].value = sensor_read(sam_client,ov9650_reg[i].subaddr);
  printk(KERN_CRIT"ov9650reg value:[0x%02x][0x%02x]\r\n",ov9650_reg[i].subaddr,testreg[i].value);
 }
 while(1)
  {
        sensor_write(sam_client, 0x35,0x78);
     delay(20);
     testreg[1].value = sensor_read(sam_client,10);
   printk(KERN_CRIT"ov9650reg value:[0x%x]\r\n",testreg[1].value);
  }
        printk(KERN_CRIT"[CAM DRV]-sensor_testreg\n");
}

void inline sensor_init(struct i2c_client *sam_client)
{
 int i;
 //i = (sizeof(ov9650_reg)/sizeof(ov9650_reg[0]));

        printk(KERN_CRIT"[CAM DRV]+sensor_init\n");
 for (i = 0; i < OV9650_INIT_REGS; i++) {
  delay(50);
  sensor_write(sam_client,ov9650_reg[i].subaddr, ov9650_reg[i].value);
#if 0
   printk(KERN_ERR "Page:[%03d] Subaddr %02x = 0x%02x\n",i,
          ov9650_reg[i].subaddr,
          ov9650_reg[i].value);
#endif
 }

#ifdef YOU_WANT_TO_CHECK_IMG_SENSOR
 for (i = 0; i < OV9650_INIT_REGS; i++) {
  if (ov9650_reg[i].subaddr == PAGE_ADDRESS) {
   sensor_write(sam_client,
         ov9650_reg[i].subaddr,
         ov9650_reg[i].value);

   printk(KERN_ERR "Page: Subaddr %02x = 0x%02x\n",
          ov9650_reg[i].subaddr,
          ov9650_reg[i].value);


  } else {
   ov9650_regs_mirror[i].subaddr =
       ov9650_reg[i].subaddr;
   ov9650_regs_mirror[i].value =
       s5k3aa_read(sam_client, ov9650_reg[i].subaddr);
   printk(KERN_ERR "Subaddr %02x = 0x%02x\n",
          ov9650_reg[i].subaddr,
          ov9650_regs_mirror[i].value);
  }
 }
#endif
        printk(KERN_CRIT"[CAM DRV]-sensor_init\n");
}


static int
ov9650_attach(struct i2c_adapter *adap, int addr,  int  flags )
{
 struct i2c_client *c;
 int ret = 0;
 //unsigned char a = 0xff;

        printk(KERN_CRIT"[CAM DRV]+ov9650_attach\n");
 c = kmalloc(sizeof(*c), GFP_KERNEL);
 if (!c)
  return -ENOMEM;

 memset(c, 0, sizeof(struct i2c_client));     

 strcpy(c->name, "ov9650");
 c->addr = addr;
 c->adapter = adap;
 c->driver = &ov9650_driver;
 ov9650_data.sensor = c;

 ret = i2c_attach_client(c);
 
 //a = sensor_read(c,10);
 //printk("0V9650.C:CAMERA ID: 0x%x\r\n",a);
 
        printk(KERN_CRIT"[CAM DRV]-ov9650_attach\n");
 return ret;
}

static int sensor_probe(struct i2c_adapter *adap)
{
        printk(KERN_CRIT"[CAM DRV]+sensor_probe\n");
        printk(KERN_CRIT"[CAM DRV]-sensor_probe\n");
 
        return i2c_probe(adap, &addr_data, ov9650_attach);
}

static int sensor_detach(struct i2c_client *client)
{
        printk(KERN_CRIT"[CAM DRV]+sensor_detach\n");
        i2c_detach_client(client);
        printk(KERN_CRIT"[CAM DRV]-sensor_detach\n");
        return 0;
}

static int change_sensor_size(struct i2c_client *client, int size)
{
 int i;

        printk(KERN_CRIT"[CAM DRV]+change_sensor_size\n");
 switch (size) {

 case SENSOR_VGA:
  for (i = 0; i < OV9650_VGA_REGS; i++) {
   delay(50);
   sensor_write(client, ov9650_reg_vga[i].subaddr,
         ov9650_reg_vga[i].value);
  }
  break;
 case SENSOR_SXGA:
  for (i = 0; i < OV9650_SXGA_REGS; i++) {
   delay(50);
   sensor_write(client, ov9650_reg_sxga[i].subaddr,
         ov9650_reg_sxga[i].value);
  }
  break;
  

 case SENSOR_SVGA:
  for (i = 0; i < OV9650_INIT_REGS; i++) {
   delay(50);
   sensor_write(client, ov9650_reg[i].subaddr,
         ov9650_reg[i].value);
  }
  break;

 default:
  panic("ov9650.c: unexpect value \n");
 }

        printk(KERN_CRIT"[CAM DRV]-change_sensor_size\n");
 return 0;
}

static int change_sensor_wb(struct i2c_client *client, int type)
{
        printk(KERN_CRIT"[CAM DRV]+change_sensor_wb\n");
       printk("[ *** Page 0, OV9650 Sensor White Balance Mode ***]\n");
       
       sensor_write(client, 0xFC, 0x0);
       sensor_write(client, 0x30, type);

       switch(type){
           case 0:
           default:
                printk(" -> AWB auto mode ]\n");
                break;
           case 1:
                printk(" -> Indoor 3100 mode ]\n");
                break;
           case 2:
                printk(" -> Outdoor 5100 mode ]\n");
                break;
           case 3:
                printk(" -> Indoor 2000 mode ]\n");
                break;
           case 4:
                printk(" -> AE/AWB halt ]\n");
                break;
           case 5:
                printk(" -> Cloudy(6000) mode ]\n");
                break;
           case 6:
                printk(" -> Sunny(8000) mode ]\n");
                break;
       }

        printk(KERN_CRIT"[CAM DRV]-change_sensor_wb\n");
       return 0;
}

static int
sensor_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
        printk(KERN_CRIT"[CAM DRV]+sensor_command\n");
 switch (cmd) {
 case SENSOR_INIT:
  sensor_init(client);
  printk("External Camera initialized\n");
  break;
  
 case USER_ADD:
  //MOD_INC_USE_COUNT;
  break;
  
 case USER_EXIT:
  //MOD_DEC_USE_COUNT;
  //sensor_testreg(client);
  break;
  
 case SENSOR_VGA:
  printk("change_sensor_size:SENSOR_VGA\n");
  change_sensor_size(client, SENSOR_VGA);
  break;
  
 case SENSOR_SVGA:
  printk("change_sensor_size:SENSOR_SVGA\n");
  change_sensor_size(client, SENSOR_SVGA);
  break;
  
 case SENSOR_SXGA:
  printk("change_sensor_size:SENSOR_SXGA\n");
  change_sensor_size(client, SENSOR_SXGA);
  break;
  
 case SENSOR_UXGA:
  printk("change_sensor_size:SENSOR_UXGA\n");
  change_sensor_size(client, SENSOR_UXGA);
  break;
/* Todo
 case SENSOR_BRIGHTNESS:
  change_sensor();
  break;
*/
 case SENSOR_WB:
         printk("[ *** OV9650 Sensor White Balance , No mode ***]\n");
         change_sensor_wb(client, (int)arg);
         break;
 
 default:
  panic("ov9650.c : Unexpect Sensor Command \n");
  break;
 }
 
        printk(KERN_CRIT"[CAM DRV]-sensor_command\n");
 return 0;
}

static struct i2c_driver ov9650_driver = {
 .driver = {
  .name = "ov9650",
 },
      .id = I2C_DRIVERID_OVCAMCHIP,
      .attach_adapter = sensor_probe,
      .detach_client = sensor_detach,
      .command = sensor_command
};

static int ov9650_sensor_init(void)
{
 int ret;

        printk(KERN_CRIT"[CAM DRV]+ov9650_sensor_init\n");
 s3c_camif_open_sensor(&ov9650_data);

 if (ov9650_data.sensor == NULL)
  if ((ret = i2c_add_driver(&ov9650_driver)))
   return ret;

 if (ov9650_data.sensor == NULL) {
  i2c_del_driver(&ov9650_driver); 
  return -ENODEV;
 }

 s3c_camif_register_sensor(&ov9650_data);

        printk(KERN_CRIT"[CAM DRV]-ov9650_sensor_init\n");
 return 0;
}

static void ov9650_sensor_exit(void)
{
        printk(KERN_CRIT"[CAM DRV]+ov9650_sensor_add\n");
        if (ov9650_data.sensor != NULL)
            s3c_camif_unregister_sensor(&ov9650_data);
        printk(KERN_CRIT"[CAM DRV]+ov9650_sensor_add\n");
}

static struct v4l2_input ov9650_input = {
 //第幾個camera輸入
 .index  = 0,
 //cmos name 
 .name  = "Camera Input (OV9650)",
 //V4L2_INPUT_TYPE_TUNER 1 This input uses a tuner (RF demodulator).
        //V4L2_INPUT_TYPE_CAMERA 2 Analog baseband input, for example CVBS
        //Composite Video, S-Video, RGB.
 .type  = V4L2_INPUT_TYPE_CAMERA, 
        //Video inputs combine with zero or more audio inputs.
 .audioset = 0,
 //Capture devices can have zero or more tuners
 .tuner  = 0,
        //Every video input supports one or more different video standards 
 .std  = V4L2_STD_PAL_BG | V4L2_STD_NTSC_M,
        //
 .status  = 0,
};

static struct v4l2_input_handler ov9650_input_handler = {
 ov9650_sensor_init,
 ov9650_sensor_exit
};

static __init int ov9650_sensor_add(void)
{
        printk(KERN_CRIT"[CAM DRV]+ov9650_sensor_add\n");
        printk(KERN_CRIT"[CAM DRV]-ov9650_sensor_add\n");
        return s3c_camif_add_sensor(&ov9650_input, &ov9650_input_handler);
}

static __exit void ov9650_sensor_remove(void)
{
        printk(KERN_CRIT"[CAM DRV]+ov9650_sensor_remove\n");
        if(ov9650_data.sensor != NULL)
        {
            i2c_del_driver(&ov9650_driver); 
        } 

        s3c_camif_remove_sensor(&ov9650_input, &ov9650_input_handler);
        printk(KERN_CRIT"[CAM DRV]-ov9650_sensor_remove\n");
}

module_init(ov9650_sensor_add)
module_exit(ov9650_sensor_remove)

2010年11月10日 星期三

MIDC

ProjectMIDC

BIOS:
--英文Basic Input/output System的縮寫,意思是“基本輸入/輸出系統”。

實際上它是被固化在電腦ROM(只讀記憶體)晶片上的一組程式(但大多數人把他當成了一塊
晶片或是CMOS),為電腦提供最低級的、最直接的硬體控制與支援。更形象地說,BIOS就是硬體與軟體程式之間的一個橋梁或者說是介面(雖然它本身也只是一個程式) ,負責解決硬體的即時需求,並按軟體對硬體的操作要求具體執行。負責在電腦開啟時檢測、初始化系統設備、裝入作業系統並調度作業系統向硬體發出的指令。

Embedded Controller:
--即:嵌入式控制器,簡稱EC。
EC在筆記本電腦中有著相當重要的作用,用於控制主要I/O的周邊設備,例如:鍵盤、滑鼠、觸控板等。EC中一般內建某種型號的微處理器(如8032),可以讓筆記本完成各種複雜的ACPI電源管理(包括風扇控制管理)等等。EC除了本身硬體之外,還需要Firmeare(微代碼),這個部分主要由EC廠商和和幾大BIOS生產公司(如Phonix等)配合開發完成。
很多EC都採用了share memory的架構,也就是EC的代碼和系統BIOS代碼共同儲存于同一個FlashRom內。也正是因為這一點,IBM的BIOS升級時,往往需要連同EC一塊升級。其實Embedded Controller是OS載入之前的I/O控制器。光碟機能開機USB device也能開機,這些就是Embedded Controller在做的事

主要工作小結
EC的touch key( SO340010 ) 控制

心得
對firmware有初步了解

參考書籍
1. BIOS 研發技術剖析第二版
2. 以C語言解析電腦