This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

"VIDIOC_STREAMON: Broken pipe" DM3730 processor,ov2643 camera sensor

Other Parts Discussed in Thread: DM3730, BQ27200, WL1271, OMAP3530, TVP5146, AM3517

Hi,

I am using DM3730 processor, ov2643 2M pixel camera. when I run the application "VIDIOC_STREAMON: Broken pipe" occurred. After kernel log I attached the C video capture application and I attached the target log. I don't have  idea how to solve this error please give the solution about this error.

when i am sending ioctl parameters for capture image or video these error came. When I execute the application the  ioctl  VIDIOC_STREAMON received in  driver isp3video.c get the parameters and returns NULL thats why ioctl returns [-1] . Please give the solution for solve this error.

I have taken the application v4l2 API example

please anyone suggest me gstreamer prebuild binaries for image and video capture using gstreamer pipeline.

Here I attached all logs:

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

Driver detected:
  
root@beagleboard:/# cat sys/bus/i2c/devices/i2c-2/2-0030/name
ov2643
-----------------------------------------------------------------------------------------

Device mounted:

root@beagleboard:/# cat /sys/devices/platform/omap3isp/video4linux/video*/name
OMAP3 ISP CCP2 input
OMAP3 ISP CSI2a output
OMAP3 ISP CCDC output
OMAP3 ISP preview input
OMAP3 ISP preview output
OMAP3 ISP resizer input
OMAP3 ISP resizer output

amet@beagleboard:/# cat /sys/devices/platform/omap3isp/video4linux/v4l-subdev*/na
OMAP3 ISP CCP2
OMAP3 ISP CSI2a
OMAP3 ISP CCDC
OMAP3 ISP preview
OMAP3 ISP resizer
OMAP3 ISP AEWB
OMAP3 ISP AF
OMAP3 ISP histogram
ov2643 2-0030
--------------------------------------------------------------------

kernel version: 3.0.8

Target               : OMAP3 Beagle Board

camera             : ov2643

==========================================================================================

Target Log:

Media: Opened Media Device
======media device opened========
E[ 2424.490356] return value of entity->type 20000
numerating media[ 2424.495422] return value of entity->type 20000
 entities
[1]:O[ 2424.501617] return value of entity->type 20000
MAP3 ISP CCP2
[[ 2424.507751] return value of entity->type 20000
2]:OMAP3 ISP CCP[ 2424.513916] return value of entity->type 20000
2 input
[3]:OMA[ 2424.520050] return value of entity->type 20000
P3 ISP CSI2a
[4[ 2424.526214] return value of entity->type 20000
]:OMAP3 ISP CSI2[ 2424.532379] return value of entity->type 20000
a output
[5]:OM[ 2424.538543]  Entered ov2643 set power
AP3 ISP CCDC
[6[ 2424.543792] return value of entity->type 20000
]:OMAP3 ISP CCDC[ 2424.549926] return value of entity->type 20000
 output
[7]:OMA[ 2424.556091] return value of entity->type 10000
P3 ISP preview
[8]:OMAP3 ISP pr[ 2424.564849] ********* video get input ***************
eview input
[9][ 2424.570434]
[ 2424.570434] ########################## From driver - ispvideo.c - input = 0 ##################################
:OMAP3 ISP previ[ 2424.584594]
[ 2424.584594] ##################### From driver - ispvideo.c - setting input name #########################
ew output
[10]:[ 2424.597534]
[ 2424.597564] ##################### From driver - ispvideo.c - setting input name #########################
OMAP3 ISP resize[ 2424.610443] ************* entering query standard ******************
r
[11]:OMAP3 IS[ 2424.619323]  for loop execution time = 0
[ 2424.623535]  for loop execution time = 1

[12]:OMAP3 ISP [ 2424.629028]  Executing the continue statement
resizer output
[ 2424.635101]  for loop execution time = 2
[13]:OMAP3 ISP A[ 2424.640624]  Executing the continue statement
EWB
[14]:OMAP3 [ 2424.646697]  for loop execution time = 3
ISP AF
[15]:OMA[ 2424.652221]  Executing the continue statement
P3 ISP histogram[ 2424.658294]  for loop execution time = 4

[16]:ov2643 2-[ 2424.663818]  Executing the continue statement
0030
Total numb[ 2424.669891]  for loop execution time = 5
er of entities: [ 2424.675384]  for loop execution time = 6
16
Enumerating [ 2424.680908]  for loop execution time = 7
links/pads for e[ 2424.686431]  for loop execution time = 8
ntities
pads fo[ 2424.691925] Returning link->source
r entity 1=(0 INPUT) (1 OUTPUT) [ 2424.699737]  for loop execution time = 0

[1:1]===>[5:0][ 2424.703979]  for loop execution time = 1
        INACTIVE

pa[ 2424.709503]  Executing the continue statement
ds for entity 2=[ 2424.715545]  for loop execution time = 2
(0 OUTPUT)
[2:[ 2424.721069]  Executing the continue statement
0]===>[1:0]     INAC[ 2424.727142]  for loop execution time = 3
TIVE

pads fo[ 2424.732666]  Executing the continue statement
r entity 3=(0 IN[ 2424.738708]  for loop execution time = 4
PUT) (1 OUTPUT) [ 2424.744262]  Executing the continue statement

[3:1]===>[4:0][ 2424.750305]  for loop execution time = 5
        INACTIVE
[3:1[ 2424.755859]  for loop execution time = 6
]===>[5:0]      INACT[ 2424.761352]  for loop execution time = 7
IVE

pads for[ 2424.766876]  for loop execution time = 8
 entity 4=(0 INP[ 2424.772399] Returning link->source
UT)

pads for entity 5=(0 INP[ 2424.779937]  for loop execution time = 0
UT) (1 OUTPUT) ([ 2424.784362]  for loop execution time = 1
2 OUTPUT)
[5:1[ 2424.789916]  Executing the continue statement
]===>[6:0]      ACTIV[ 2424.795989]  for loop execution time = 2
E
[5:2]===>[7:0[ 2424.801483]  Executing the continue statement
]       INACTIVE
[5:[ 2424.807556]  for loop execution time = 3
1]===>[10:0]    INA[ 2424.813079]  Executing the continue statement
CTIVE
[5:2]===[ 2424.819152]  for loop execution time = 4
>[13:0] ACTIVE
[ 2424.824645]  Executing the continue statement
[5:2]===>[14:0] [ 2424.830718]  for loop execution time = 5
ACTIVE
[5:2]===[ 2424.836242]  for loop execution time = 6
>[15:0] ACTIVE
[ 2424.841766]  for loop execution time = 7

pads for entit[ 2424.847259]  for loop execution time = 8
y 6=(0 INPUT)
[ 2424.852783] Returning link->source

pads for entity 7=(0 INPUT) (1[ 2424.860504]  Entered ov2643 open
 OUTPUT)
[7:1][ 2424.864074]  Entered ov2643 set power
===>[9:0]       INACTI[ 2424.869781]  Entered ov2643 set format
VE
[7:1]===>[1[ 2424.874694]  Entered ov2643 v4l2 try fmt cap
0:0]    INACTIVE
[ 2424.880584]  Entered ov2643 calc size

pads for entit[ 2424.886566] ==== Entering isp video mbus to pix ==== ispvideo.c ====
[ 2424.893920] Return 2 executed (m to p)

[8:0]===>[7:0]  INACTIVE

pads for entity 9=(0 INPUT)

pads for entity 10=(0 INPUT) (1 OUTPUT)
[10:1]===>[12:0]        INACTIVE

pads for entity 11=(0 OUTPUT)
[11:0]===>[10:0]        INACTIVE

pads for entity 12=(0 INPUT)

pads for entity 13=(0 INPUT)

pads for entity 14=(0 INPUT)

pads for entity 15=(0 INPU[ 2424.927307] *************** stream on accessed *********************
T)

pads for [ 2424.934692] *************** stream on accessed *********************
entity 16=(0 OUT[ 2424.942413]
[ 2424.942413] ##################### entering stream on ########################
PUT)
[16:0]===[ 2424.952880] =======isp_video_check_format======ispvideo.c===
>[5:0]  ACTIVE
[ 2424.960205] =======Entering isp_video_get_format=======ispvideo.c====

Enabling link [[ 2424.968383] ======isp_video_remote_subdev=========ispvideo.c==
ov2643]===>[ccdc[ 2424.975891]  for loop execution time = 0
]
[ov2643]===>[[ 2424.981384] Returning link->source
ccdc]   enabled
E[ 2424.986480]  Return value of remote = -294752892
nabling link [cc[ 2424.992828] return value of entity->type 20000
dc]===>[video_no[ 2424.998962] Returning media entity to v4l2 subdev
de]
[ccdc]===>[[ 2425.005371] ==== Entering isp video mbus to pix ==== ispvideo.c ====
video_node]     enab[ 2425.013397] Return 2 executed (m to p)
led
======media[ 2425.018798] Return value afer IF condition = 0
 device closed==[ 2425.024963]
[ 2425.024993] #################### ret = isp_video_check_format(video, vfh);########################*
=======
Capture[ 2425.037414]
[ 2425.037445] ################### Before far_end = isp_video_far_end(video); #############################
: Current Input:[ 2425.050292] return value of entity->type 20000
 oviya-camera
C[ 2425.056457] return value of entity->type 20000
apture: Input ch[ 2425.062622] return value of entity->type 20000
anged to: oviya-[ 2425.068756] return value of entity->type 20000
camera
VIDIOC_Q[ 2425.074920] return value of entity->type 20000
UERYSTD: Invalid[ 2425.081085]
[ 2425.081085] ################### After far_end = isp_video_far_end(video); #############################
 argument
VIDIO[ 2425.093902] ======isp_video_remote_subdev=========ispvideo.c==
C_G_STD: Invalid[ 2425.101409]  for loop execution time = 0
 argument
succe[ 2425.106933] Returning link->source
ssfully format i[ 2425.111968]  Return value of remote = -294752892
s set on all pad[ 2425.118316] return value of entity->type 20000
 [WxH] - [640x48[ 2425.124481] Returning media entity to v4l2 subdev
0]
Capture: Cap[ 2425.130828] ################## isp_video_remote_subdev ######################
able of streamin[ 2425.139739]  for loop execution time = 0
g
Capture: Numb[ 2425.145233]  for loop execution time = 1
er of requested [ 2425.150756]  Executing the continue statement
buffers = 3
Cap[ 2425.156829]  for loop execution time = 2
ture: Init done [ 2425.162353]  Executing the continue statement
successfully

[ 2425.168395]  for loop execution time = 3

Display: Opene[ 2425.173919]  Executing the continue statement
d Channel
Displ[ 2425.179992]  for loop execution time = 4
ay: Capable of s[ 2425.185516]  Executing the continue statement
treaming
Displa[ 2425.191558]  for loop execution time = 5
y: Number of req[ 2425.197082]  for loop execution time = 6
uested buffers =[ 2425.202606]  for loop execution time = 7
 3
Display: Ini[ 2425.208099]  for loop execution time = 8
t done successfu[ 2425.213653] Returning link->source
lly

[0]======[ 2425.218719] return value of entity->type 20000
==display_ret_va[ 2425.224884]  Entered ov2643_get_format
lue========
Dis[ 2425.230194]  Entered ov2643 get pad fmt: 22
play: Stream on.[ 2425.235992] ov2643->format.code = 8200
..
========afte[ 2425.241333]
[ 2425.241333] ################### isp video validate pipeline  #############################
r display stream[ 2425.252960]
[ 2425.252960] ####################### video->streaming = 0 #################
 on========
[-1]========capture_ret_value========
VIDIOC_STREAMON: Broken pipe
========after capture stream on========
[ 2425.277709] return value of entity->type 20000
[ 2425.282592] return value of entity->type 20000
[ 2425.287384] return value of entity->type 20000
[ 2425.292144] return value of entity->type 20000
[ 2425.296905] return value of entity->type 20000
[ 2425.301666] return value of entity->type 20000
[ 2425.306427] return value of entity->type 20000
[ 2425.311218] return value of entity->type 20000
[ 2425.315948]  Entered ov2643 set power
[ 2425.319824] return value of entity->type 20000
[ 2425.324584] return value of entity->type 20000
[ 2425.329345] return value of entity->type 10000

Media: Opened Media Device
======media device opened========
Resetting all links...
======media device closed=========
======media device closed=========
*** glibc detected *** ./camera_app1: munmap_chunk(): invalid pointer: 0x4906d2b8 ***
Aborted
root@beagleboard:/#

==========================================================================================

Kernel log:

Booting kernel...
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0
error waiting for i2c address ACK (status=0x1012)
timed out in wait_for_bb: I2C_STAT=1000
reading uImage

3721568 bytes read
Booting from mmc ...
## Booting kernel from Legacy Image at 80007fc0 ...
   Image Name:   Linux-3.0.8
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3721504 Bytes = 3.5 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Linux version 3.0.8 (oviya@oviya-Tech) (gcc version 4.5.3 20110311 (prerelease) (GCC) ) #21 Sun May 11 10:59:43 IST 2014
[    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7f
[    0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine: OMAP3 Beagle Board
[    0.000000] Beagle expansionboard: none
[    0.000000] Truncating RAM at a0000000-bfffffff to -afffffff (vmalloc region overlap).
[    0.000000] Reserving 12582912 bytes SDRAM for VRAM
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] OMAP3630 ES1.2 (l2cache iva sgx neon isp 192mhz_clk )
[    0.000000] SRAM: Mapped pa 0x40200000 to va 0xfe400000 size: 0x10000
[    0.000000] Clocking rate (Crystal/Core/MPU): 26.0/400/600 MHz
[    0.000000] Reprogramming SDRC clock to 400000000 Hz
[    0.000000] dpll3_m2_clk rate change failed: -22
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 192000
[    0.000000] Kernel command line: console=ttyO2,115200 mpurate=auto buddy=none camera=none vram=12M omapfb.mode=dvi:1024x600MR-32@60 omapdss.def_disp=dvi root=t
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Memory: 756MB = 756MB total
[    0.000000] Memory: 754224k/754224k available, 32208k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
[    0.000000]     vmalloc : 0xf0800000 - 0xf8000000   ( 120 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .init : 0xc0008000 - 0xc0044000   ( 240 kB)
[    0.000000]       .text : 0xc0044000 - 0xc06e5050   (6789 kB)
[    0.000000]       .data : 0xc06e6000 - 0xc0747900   ( 391 kB)
[    0.000000]        .bss : 0xc0747924 - 0xc0c9a52c   (5452 kB)
[    0.000000] NR_IRQS:410
[    0.000000] IRQ: Found an INTC at 0xfa200000 (revision 4.0) with 96 interrupts
[    0.000000] Total of 96 interrupts on 1 active controller
[    0.000000] OMAP clockevent source: GPTIMER1 at 32768 Hz
[    0.000000] sched_clock: 32 bits at 32kHz, resolution 30517ns, wraps every 131071999ms
[    0.000000] Console: colour dummy device 80x30
[    0.000000] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.000000] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.000000] ... MAX_LOCK_DEPTH:          48
[    0.000000] ... MAX_LOCKDEP_KEYS:        8191
[    0.000000] ... CLASSHASH_SIZE:          4096
[    0.000000] ... MAX_LOCKDEP_ENTRIES:     16384
[    0.000000] ... MAX_LOCKDEP_CHAINS:      32768
[    0.000000] ... CHAINHASH_SIZE:          16384
[    0.000000]  memory used by lock dependency info: 3695 kB
[    0.000000]  per task-struct memory footprint: 1152 bytes
[    0.000701] Calibrating delay loop... 597.64 BogoMIPS (lpj=2334720)
[    0.093719] pid_max: default: 32768 minimum: 301
[    0.094085] Security Framework initialized
[    0.094299] Mount-cache hash table entries: 512
[    0.097473] CPU: Testing write buffer coherency: ok
[    0.105987] omap_hwmod: gpt12_fck: missing clockdomain for gpt12_fck.
[    0.112152] print_constraints: dummy:
[    0.113220] NET: Registered protocol family 16
[    0.114135] GPMC revision 5.0
[    0.122863] OMAP GPIO hardware version 2.5
[    0.124053] OMAP GPIO hardware version 2.5
[    0.125183] OMAP GPIO hardware version 2.5
[    0.126464] OMAP GPIO hardware version 2.5
[    0.127532] OMAP GPIO hardware version 2.5
[    0.128662] OMAP GPIO hardware version 2.5
[    0.133911] omap_mux_init: Add partition: #1: core, flags: 0
[    0.136077] OMAP3 Beagle Rev: Ax/Bx
[    0.137054] PMIC INIT Finished
[    0.145660] Beagle expansionboard: registering wl12xx bt platform device
[    0.146240] EVO1 board: registering wl12xx wifi platform device
[    0.146759] CONFIG OMAP MUX IS ON!!
[    0.147369] Found NAND on CS0
[    0.147399] Registering NAND on CS0
[    0.149383] Unable to get DVI reset GPIO
[    0.149749] hw-breakpoint: debug architecture 0x4 unsupported.
[    0.159027] omap_device: omap-mcbsp.2: alias fck already exists
[    0.159667] omap_device: omap-mcbsp.3: alias fck already exists
[    0.163330] OMAP DMA hardware revision 5.0
[    0.238281] bio: create slab <bio-0> at 0
[    0.241424] print_constraints: vwl1271: 1800 mV
[    0.246520] SCSI subsystem initialized
[    0.254669] usbcore: registered new interface driver usbfs
[    0.255157] usbcore: registered new interface driver hub
[    0.255798] usbcore: registered new device driver usb
[    0.273620] omap_i2c omap_i2c.1: bus 1 rev4.0 at 2600 kHz
[    0.282379] twl4030: PIH (irq 7) chaining IRQs 368..375
[    0.282501] twl4030: power (irq 373) chaining IRQs 376..383
[    0.283996] twl4030: gpio (irq 368) chaining IRQs 384..401
[    0.295501] print_constraints: VUSB1V5: 1500 mV normal standby
[    0.297607] print_constraints: VUSB1V8: 1800 mV normal standby
[    0.299285] print_constraints: VUSB3V1: 3100 mV normal standby
[    0.303710] twl4030_usb twl4030_usb: Initialized TWL4030 USB module
[    0.308013] print_constraints: VMMC1: 1850 <--> 3150 mV at 3000 mV normal standby
[    0.309844] print_constraints: VDAC: 1800 mV normal standby
[    0.311584] print_constraints: VDVI: 1800 mV normal standby
[    0.313812] print_constraints: VSIM: 1800 <--> 3000 mV at 1800 mV normal standby
[    0.328277] omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz
[    0.333343] Advanced Linux Sound Architecture Driver Version 1.0.24.
[    0.338623] cfg80211: Calling CRDA to update world regulatory domain
[    0.340942] Switching to clocksource 32k_counter
[    0.344055] Switched to NOHz mode on CPU #0
[    0.422760] musb-hdrc: version 6.0, pio, otg (peripheral+host)
[    0.428649] musb-hdrc musb-hdrc: USB OTG mode controller at fa0ab000 using PIO, IRQ 92
[    0.430389] NET: Registered protocol family 2
[    0.430847] IP route cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.432281] TCP established hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.436065] TCP bind hash table entries: 65536 (order: 9, 2359296 bytes)
[    0.469116] TCP: Hash tables configured (established 131072 bind 65536)
[    0.469207] TCP reno registered
[    0.469238] UDP hash table entries: 512 (order: 3, 40960 bytes)
[    0.469818] UDP-Lite hash table entries: 512 (order: 3, 40960 bytes)
[    0.470916] NET: Registered protocol family 1
[    0.472595] RPC: Registered named UNIX socket transport module.
[    0.472625] RPC: Registered udp transport module.
[    0.472656] RPC: Registered tcp transport module.
[    0.472656] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.473358] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.478027] omap-iommu omap-iommu.0: isp registered
[    0.656219] VFS: Disk quotas dquot_6.5.2
[    0.656280] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.658050] JFFS2 version 2.2. (NAND) (SUMMARY)  �ԩ 2001-2006 Red Hat, Inc.
[    0.658630] msgmni has been set to 1473
[    0.662506] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    0.662658] io scheduler noop registered
[    0.662658] io scheduler deadline registered
[    0.662750] io scheduler cfq registered (default)
[    0.724029] OMAP DSS rev 2.0
[    0.733428] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.739227] omap_uart.0: ttyO0 at MMIO 0x4806a000 (irq = 72) is a OMAP UART0
[    0.740966] omap_uart.1: ttyO1 at MMIO 0x4806c000 (irq = 73) is a OMAP UART1
[    0.742034] omap_uart.2: ttyO2 at MMIO 0x49020000 (irq = 74) is a OMAP UART2
[    1.478881] console [ttyO2] enabled
[    1.483703] omap_uart.3: ttyO3 at MMIO 0x49042000 (irq = 80) is a OMAP UART3
[    1.517639] brd: module loaded
[    1.533538] loop: module loaded
[    1.537933] BCICTL1 = 32
[    1.547851] mtdoops: mtd device (mtddev=name/number) must be supplied
[    1.554779] omap2-nand driver initializing
[    1.559661] NAND device: Manufacturer ID: 0xad, Chip ID: 0xbc (Hynix NAND 512MiB 1,8V 16-bit)
[    1.568725] Creating 5 MTD partitions on "omap2-nand.0":
[    1.574310] 0x000000000000-0x000000080000 : "X-Loader"
[    1.586395] 0x000000080000-0x000000260000 : "U-Boot"
[    1.596221] 0x000000260000-0x000000280000 : "U-Boot Env"
[    1.605590] 0x000000280000-0x000000680000 : "Kernel"
[    1.616607] 0x000000680000-0x000020000000 : "File System"
[    1.850830] OneNAND driver initializing
[    1.865112] usbcore: registered new interface driver catc
[    1.870788] catc: v2.8:CATC EL1210A NetMate USB Ethernet driver
[    1.877593] usbcore: registered new interface driver kaweth
[    1.883483] pegasus: v0.6.14 (2006/09/27), Pegasus/Pegasus II USB Ethernet driver
[    1.891845] usbcore: registered new interface driver pegasus
[    1.897827] rtl8150: v0.6.2 (2004/08/27):rtl8150 based usb-ethernet driver
[    1.905548] usbcore: registered new interface driver rtl8150
[    1.911987] usbcore: registered new interface driver asix
[    1.918090] usbcore: registered new interface driver cdc_ether
[    1.924713] usbcore: registered new interface driver dm9601
[    1.931121] usbcore: registered new interface driver smsc95xx
[    1.937652] usbcore: registered new interface driver gl620a
[    1.944000] usbcore: registered new interface driver net1080
[    1.950347] usbcore: registered new interface driver plusb
[    1.956634] usbcore: registered new interface driver rndis_host
[    1.963348] usbcore: registered new interface driver cdc_subset
[    1.970092] usbcore: registered new interface driver zaurus
[    1.976440] usbcore: registered new interface driver MOSCHIP usb-ethernet driver
[    1.984680] Initializing USB Mass Storage driver...
[    1.990356] usbcore: registered new interface driver usb-storage
[    1.996643] USB Mass Storage support registered.
[    2.008239] g_mass_storage gadget: Mass Storage Function, version: 2009/09/11
[    2.015777] g_mass_storage gadget: Number of LUNs=1
[    2.020935]  lun0: LUN: removable file: (no medium)
[    2.026153] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[    2.033477] g_mass_storage gadget: userspace failed to provide iSerialNumber
[    2.040924] g_mass_storage gadget: g_mass_storage ready
[    2.046447] musb-hdrc musb-hdrc: MUSB HDRC host driver
[    2.052093] musb-hdrc musb-hdrc: new USB bus registered, assigned bus number 1
[    2.063842] hub 1-0:1.0: USB hub found
[    2.068054] hub 1-0:1.0: 1 port detected
[    2.074829] mousedev: PS/2 mouse device common for all mice
[    2.083221] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    2.093963] input: TWL4030 Keypad as /devices/platform/omap/omap_i2c.1/i2c-1/1-004a/twl4030_keypad/input/input1
[    2.110931] input: twl4030_pwrbutton as /devices/platform/omap/omap_i2c.1/i2c-1/1-0049/twl4030_pwrbutton/input/input2
[    2.123992] twl_rtc twl_rtc: Power up reset detected.
[    2.129638] twl_rtc twl_rtc: Enabling TWL-RTC.
[    2.137512] twl_rtc twl_rtc: rtc core: registered twl_rtc as rtc0
[    2.145446] i2c /dev entries driver
[    2.152038] Linux media interface: v0.10
[    2.156799] Linux video capture interface: v2.00
[    2.163085]  ******************** ov2643_module_init **************************
[    2.172729] vpfe_init
[    2.176177] Driver for 1-wire Dallas network protocol.
[    2.182922] Bq27200 initialising
[    2.191650] bq27x00-battery 3-0055: support ver. 1.2.0 enabled
[    2.214050] ret = 0
[    2.216308] Bq27200 initialised
[    2.224029] OMAP Watchdog Timer Rev 0x31: initial timeout 60 sec
[    2.231536] twl4030_wdt twl4030_wdt: Failed to register misc device
[    2.238372] twl4030_wdt: probe of twl4030_wdt failed with error -16
[    2.246337] cpuidle: using governor ladder
[    2.250701] cpuidle: using governor menu
[    2.266845] usbcore: registered new interface driver usbhid
[    2.272796] usbhid: USB HID core driver
[    2.283630] OMAP3 Beagle/Devkit8000 SoC init
[    2.382019] asoc: twl4030-hifi <-> omap-mcbsp-dai.1 mapping ok
[    2.401519] ALSA device list:
[    2.404724]   #0: omap3beagle
[    2.407836] oprofile: hardware counters not available
[    2.413146] oprofile: using timer interrupt.
[    2.418121] TCP cubic registered
[    2.421569] Initializing XFRM netlink socket
[    2.426177] NET: Registered protocol family 17
[    2.430969] NET: Registered protocol family 15
[    2.435913] lib80211: common routines for IEEE802.11 drivers
[    2.441894] Registering the dns_resolver key type
[    2.447326] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[    2.455413] ThumbEE CPU extension supported.
[    2.484588] sr_init: No PMIC hook to init smartreflex
[    2.490295] smartreflex smartreflex.0: omap_sr_probe: SmartReflex driver initialized
[    2.499053] smartreflex smartreflex.1: omap_sr_probe: SmartReflex driver initialized
[    2.508270] SmartReflex Class3 initialized
[    2.512573]  ***************** Entering beagle camera init *****************
[    2.536712] omap_i2c omap_i2c.2: bus 2 rev4.0 at 400 kHz
[    2.545532]  *********** omap3 init camera *******************
[    2.553222] omap3isp omap3isp: Revision 15.0 found
[    2.558471] omap-iommu omap-iommu.0: isp: version 1.1
[    2.563903]  ********************** omap3isp video init *************************
[    2.571929]  ********************** omap3isp video init *************************
[    2.579925]  ********************** omap3isp video init *************************
[    2.588165]  ********************** omap3isp video init *************************
[    2.596160]  ********************** omap3isp video init *************************
[    2.604156]  ********************** omap3isp video init *************************
[    2.612121]  ********************** omap3isp video init *************************
[    2.621307] isp_register_entities: V4L2 device registration success (0)
[    2.629913] omap3isp_video_register: registered video device (0)
[    2.637054] omap3isp_video_register: registered video device (0)
[    2.643402] ====omap3isp_ccdc_register_entities========ispccdc.c=====
[    2.650939] omap3isp_video_register: registered video device (0)
[    2.658050] omap3isp_video_register: registered video device (0)
[    2.665069] omap3isp_video_register: registered video device (0)
[    2.672088] omap3isp_video_register: registered video device (0)
[    2.679138] omap3isp_video_register: registered video device (0)
[    2.687469]  ************************** ov2643_probe ***************************
[    2.695465] ********* v4l2 subdev i2c init ::::: ov2643 2-0030
[    2.701477]  Entered: ov2643 regsitered
[    2.705688]  Entered ov2643 set power
[    2.709777]  Entered ov2643 power on
[    2.713500]  ************* ov2643 reset from init function ***************
[    2.731964]  ************* ov2643 reset from init function ***************
[    2.740966] mmc0: host does not support reading read-only switch. assuming write-enable.
[    2.749511]  Entered ov2643 reset
[    2.775329] Initialising OV2643 registers
[    2.779724] mmc0: new SDHC card at address e624
[    2.787170] mmcblk0: mmc0:e624 SU04G 3.69 GiB
[    2.811004]  mmcblk0: p1 p2
[    2.940612] mmc1: card claims to support voltages below the defined range. These will be ignored.
[    2.964447] mmc1: queuing unknown CIS tuple 0x91 (3 bytes)
[    2.972137] mmc1: new SDIO card at address 0001
[    3.348419]  Entered ov2643 video probe
[    3.358520] ov2643 2-0030: Detected a chip with ID: 2643
[    3.364105] Detected OV2643 chip!!!
[    3.367797]  Entered ov2643 set power
[    3.371643] isp_register_subdev_group: registered subdev ov2643
[    3.412078] clock: disabling unused clocks to save power
[    3.421478] fbcvt: Aspect ratio not CVT standard
[    3.426330] fbcvt: 1024x600@60: CVT Name - Not a CVT standard - 0.614 Mega Pixel Image
[    3.426330]
[    3.468170] Console: switching to colour frame buffer device 128x37
[    3.492004] regulator_init_complete: VDAC: incomplete constraints, leaving on
[    3.501586] twl_rtc twl_rtc: setting system clock to 2000-01-01 00:00:01 UTC (946684801)
[    3.510894] omap_vout omap_vout: Buffer Size = 3686400
[    3.518524] omap_vout omap_vout: : registered and initialized video device 16
[   64.133850] wl1271: ERROR could not get nvs file: -2
[   64.148681] wl1271: loaded
[   64.151550] wl1271: initialized
[   64.164215] EXT3-fs: barriers not enabled
[   64.173522] kjournald starting.  Commit interval 5 seconds
[   64.205047] EXT3-fs (mmcblk0p2): using internal journal
[   64.211090] EXT3-fs (mmcblk0p2): mounted filesystem with ordered data mode
[   64.218749] VFS: Mounted root (ext3 filesystem) on device 179:2.
[   64.225250] Freeing init memory: 240K
INIT: version 2.88 booting
Starting udev
[   66.758758]  Entered ov2643 open
[   66.762176]  Entered ov2643 set power
[   66.766113]  Entered ov2643 power on
[   66.769836]  ************* ov2643 reset from init function ***************
[   66.806060] return value of entity->type 10000
[   66.814422] return value of entity->type 10000
[   66.822631] return value of entity->type 10000
[   66.907104] return value of entity->type 10000
[   66.915344] return value of entity->type 10000
[   66.967956] return value of entity->type 10000
[   66.973632] return value of entity->type 10000
[   66.982299] return value of entity->type 10000
[   66.987548] return value of entity->type 10000
[   67.037933] return value of entity->type 10000
[   67.047515] return value of entity->type 10000
[   67.054077] return value of entity->type 10000
[   67.078216]  ************* ov2643 reset from init function ***************
[   67.107971] return value of entity->type 10000
[   67.115325] return value of entity->type 10000
[   67.241394]  Entered ov2643 reset
[   67.330200] Initialising OV2643 registers
ERROR: could not open directory /lib/modules/3.0.8: No such file or directory
WARNING: -e needs -E or -F
ERROR: could not open directory /lib/modules/3.0.8: No such file or directory
FATAL: could not search modules: No such file or directory
Starting Bootlog daemon: bootlogd: cannot allocate pseudo tty: No such file or directory
bootlogd.
ALSA: Restoring mixer settings...
Configuring network interfaces... ifconfig: SIOCGIFFLAGS: No such device
done.
Fri May  3 15:02:00 UTC 2013
INIT: Entering runlevel: 5
Starting system message bus: dbus.
Starting telnet daemon.
Starting syslogd/klogd: done
Starting thttpd.
Stopping Bootlog daemon: bootlogd.

 _____                    _____           _         _   
|  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_
|     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|
|__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_|  
              |___|                    |___|            

Arago Project http://arago-project.org beagleboard ttyO2

Arago 2013.02 beagleboard ttyO2

beagleboard login: root
root@beagleboard:~#
==========================================================================================

ISP Camera capture Application I have taken from Internet.

Application:

/*
 * saMmapLoopback.c
 *
 * Application used to do NTSC loopback in MMAP memory mode
 *
 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
 *
 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *    Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 *    Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the
 *    distribution.
 *
 *    Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
*/
 
 
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
 
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
 
#include <linux/media.h>
#include <linux/v4l2-mediabus.h>
#include <linux/v4l2-subdev.h>
#include <linux/videodev.h>
#include <linux/videodev2.h>
 
 
#define CONFIG_OMAP3530    1
#define FILE_WRITE  
#define V4L2_CID_ROTATE                (V4L2_CID_BASE+34)
//#define MEDIA_ENT_ID_FLAG_NEXT        (1 << 31)
/* structure used to store information of the buffers */
struct buf_info {
    int index;
    unsigned int length;
    char *start;
};
 
struct media_dev {
    /* Media device */
    int media_fd;
    /* either tvp5146 or ov2643 */
    int input_source;
    /* All entities */
    struct media_entity_desc entity[20];
    /* Entities we do care about */
    int video;    /* Streaming entity */
    int ccdc;
    int tvp5146;
    int ov2643;
    //int ov2643;
 
    /* Total number of entities */
    unsigned int num_entities;
};
 
struct capture_dev {
    int capture_fd;
 
    struct v4l2_format capture_fmt;
    struct v4l2_buffer capture_buf;
 
    int tvp_input;    /* Only applicable for tvp5146 */
 
    unsigned int num_bufs;
    /* Width and height for current input */
    unsigned int width;
    unsigned int height;
};
 
struct display_dev {
    int display_fd;
 
    struct v4l2_format display_fmt;
    struct v4l2_buffer display_buf;
 
    unsigned int num_bufs;
    /* Width and height for current input */
    unsigned int width;
    unsigned int height;
};
 
/* Changing the following will result in different number of buffers used */
#if defined (CONFIG_AM3517)
#define CAPTURE_DEVICE        "/dev/video0"
#define DISPLAY_DEVICE        "/dev/video1"
#elif defined (CONFIG_OMAP3530)
#define CAPTURE_DEVICE        "/dev/video2"
#define DISPLAY_DEVICE        "/dev/video7"
#define MEDIA_DEVICE        "/dev/media0"
 
/* Media entity names */
#define ENTITY_VIDEO_CCDC_OUT_NAME    "OMAP3 ISP CCDC output"
#define ENTITY_CCDC_NAME        "OMAP3 ISP CCDC"
#define ENTITY_TVP514X_NAME        "tvp514x 3-005c"
#define ENTITY_OV2643_NAME        "ov2643 2-0030"
//#define ENTITY_OV2643_NAME        "ov2643 2-0030"
#endif
 
#define NUM_BUFFERS         3
#define CAPTURE_MAX_BUFFER    NUM_BUFFERS
#define DISPLAY_MAX_BUFFER    NUM_BUFFERS
#define CAPTURE_NAME        "Capture"
#define DISPLAY_NAME        "Display"
#define MEDIA_NAME        "Media"
 
/* number of frames to be captured and displayed */
#define MAXLOOPCOUNT        1000
 
#define DEF_PIX_FMT        V4L2_PIX_FMT_YUYV
#define IMG_WIDTH            640
#define IMG_HEIGHT            480
 
/* capture_buff_info and display_buff_info stores buffer information of capture
   and display respectively. */
static struct buf_info capture_buff_info[CAPTURE_MAX_BUFFER];
static struct buf_info display_buff_info[DISPLAY_MAX_BUFFER];
 
/* Function declaration */
static int  open_video_dev(const char *dev, int *capture_fd);
 
/*
 * Media-Controller Framework:
 *    Setup the Links and formats.
 */
#if defined (CONFIG_OMAP3530)
static int media_device_open(struct media_dev *media)
{
    /* Open the Media device */
    media->media_fd = open((const char *) MEDIA_DEVICE, O_RDWR);
    if (media->media_fd  <= 0) {
        printf("Cannot open = %s device\n", MEDIA_DEVICE);
        return -1;
    }
    printf("\n%s: Opened Media Device\n", MEDIA_NAME);
    printf("======media device opened========\n");
    return 0;
}
 
static void media_device_close(int media_fd)
{
    /* Close the Media device */
    close(media_fd);
    printf("======media device closed=========\n");
}
 
static int enumerate_all_entities(struct media_dev *media)
{
    int ret, index;
 
    printf("Enumerating media entities\n");
    index = 0;
    do {
        memset(&media->entity[index], 0, sizeof(struct media_entity_desc));
        //media->entity[index].id = index | MEDIA_ENTITY_ID_FLAG_NEXT;
                  media->entity[index].id = index | MEDIA_ENT_ID_FLAG_NEXT;
        ret = ioctl(media->media_fd, MEDIA_IOC_ENUM_ENTITIES, &media->entity[index]);
        if (ret < 0) {
            break;
        } else {
            if (!strcmp(media->entity[index].name, ENTITY_VIDEO_CCDC_OUT_NAME))
                media->video =  media->entity[index].id;
            else if (!strcmp(media->entity[index].name, ENTITY_TVP514X_NAME))
                media->tvp5146 =  media->entity[index].id;
            //else if (!strcmp(media->entity[index].name, ENTITY_OV2643_NAME))
            //    media->ov2643 =  media->entity[index].id;
            else if (!strcmp(media->entity[index].name, ENTITY_CCDC_NAME))
                media->ccdc =  media->entity[index].id;
            else if (!strcmp(media->entity[index].name, ENTITY_OV2643_NAME))
                media->ov2643 =  media->entity[index].id;
            printf("[%d]:%s\n", media->entity[index].id, media->entity[index].name);
        }
        index++;
    } while (ret == 0);
 
    if ((ret < 0) && (index <= 0)) {
        printf("Failed to enumerate entities OR no entity registered - %d\n",
                ret);
        return ret;
    }
    media->num_entities = index;
    printf("Total number of entities: %d\n", media->num_entities);
 
    return 0;
}
 
 
static int reset_media_links(struct media_dev *media)
{
    struct media_link_desc link;
    struct media_links_enum links;
    int ret, index, i;
 
    /* Open the Media device */
    ret  = media_device_open(media);
    if (ret < 0)
        return ret;
 
    printf("Resetting all links...\n");    
    for(index = 0; index < media->num_entities; index++) {
    //    printf("=======Reset_media_links========\n");
        links.entity = media->entity[index].id;
        links.pads = malloc(sizeof( struct media_pad_desc) * media->entity[index].pads);
        links.links = malloc(sizeof(struct media_link_desc) * media->entity[index].links);
        ret = ioctl(media->media_fd, MEDIA_IOC_ENUM_LINKS, &links);
    //    printf("========[%d]ret value of enumeration links=======\n");
        if (ret < 0) {
            printf("Error while enumeration links/pads - %d\n", ret);
            break;
        } else {
            for(i = 0; i < media->entity[index].links; i++) {
                link.source.entity = links.links->source.entity;
                link.source.index = links.links->source.index;
                link.source.flags = MEDIA_PAD_FLAG_OUTPUT;
                link.sink.entity = links.links->sink.entity;
                link.sink.index = links.links->sink.index;
                link.sink.flags = MEDIA_PAD_FLAG_INPUT;
                link.flags = (link.flags & ~MEDIA_LINK_FLAG_ENABLED) |
                    (link.flags & MEDIA_LINK_FLAG_IMMUTABLE);
                ret = ioctl(media->media_fd, MEDIA_IOC_SETUP_LINK, &link);
                if(ret)
                    break;
                links.links++;
            }
        }
    }
    media_device_close(media->media_fd);
    return 0;
}
 
static int setup_media_links(struct media_dev *media)
{
    struct media_link_desc link;
    struct media_links_enum links;
    int ret, index, i, input;
 
    printf("Enumerating links/pads for entities\n");
 
    for(index = 0; index < media->num_entities; index++) {
 
 
        links.entity = media->entity[index].id;
        links.pads = malloc(sizeof( struct media_pad_desc) * media->entity[index].pads);
        links.links = malloc(sizeof(struct media_link_desc) * media->entity[index].links);
 
 
        ret = ioctl(media->media_fd, MEDIA_IOC_ENUM_LINKS, &links);
        if (ret < 0) {
            printf("Error while enumeration links/pads - %d\n", ret);
            break;
        } else {
            if(media->entity[index].pads)
                printf("pads for entity %d=", media->entity[index].id);
 
            for(i = 0 ; i < media->entity[index].pads; i++) {
 
 
                printf("(%d %s) ", links.pads->index,
                        (links.pads->flags & MEDIA_PAD_FLAG_INPUT) ?
                        "INPUT" : "OUTPUT");
                links.pads++;
            }
            printf("\n");
            for(i = 0; i < media->entity[index].links; i++) {
                printf("[%d:%d]===>[%d:%d]",
                        links.links->source.entity,
                        links.links->source.index,
                        links.links->sink.entity,
                        links.links->sink.index);
                if(links.links->flags & MEDIA_LINK_FLAG_ENABLED)
                    printf("\tACTIVE\n");
                else
                    printf("\tINACTIVE \n");
                links.links++;
            }
            printf("\n");
        }
    }
 
 
    input = media->ov2643;
 
    printf("Enabling link [ov2643]===>[ccdc]\n");
    memset(&link, 0, sizeof(link));
 
    link.flags |=  MEDIA_LINK_FLAG_ENABLED;
    link.source.entity = input;
    link.source.index = 0;    /* Only 1 pad */
    link.source.flags = MEDIA_PAD_FLAG_OUTPUT;
 
    link.sink.entity = media->ccdc;
    link.sink.index = 0; /* Sink pad of CCDC, 0 */
    link.sink.flags = MEDIA_PAD_FLAG_INPUT;
 
    ret = ioctl(media->media_fd, MEDIA_IOC_SETUP_LINK, &link);
    if(ret) {
        printf("failed to enable link between ov2643 and ccdc\n");
        return ret;
    } else {
        printf("[ov2643]===>[ccdc]\tenabled\n");
    }
    /* Enable 'ccdc===>memory' link */
    printf("Enabling link [ccdc]===>[video_node]\n");
    memset(&link, 0, sizeof(link));
 
    link.flags |=  MEDIA_LINK_FLAG_ENABLED;
    link.source.entity = media->ccdc;
    link.source.index = 1; /* Source pad of CCDC: 1 */
    link.source.flags = MEDIA_PAD_FLAG_OUTPUT;
 
    link.sink.entity = media->video;
    link.sink.index = 0;
    link.sink.flags = MEDIA_PAD_FLAG_INPUT;
 
    ret = ioctl(media->media_fd, MEDIA_IOC_SETUP_LINK, &link);
    if(ret){
        printf("failed to enable link between ccdc and video node\n");
    }
    else
        printf("[ccdc]===>[video_node]\tenabled\n");
 
    return ret;
}
 
static int set_subdev_format(struct media_dev *media,
                struct capture_dev *capture)
{
    struct v4l2_subdev_format fmt;
    int ov2643_fd, ccdc_fd, ret;
    char subdev[20];
 
    /* TODO: Should be having some mechanism to select subdev */
    ccdc_fd = open("/dev/v4l-subdev2", O_RDWR);
    if(ccdc_fd == -1) {
        printf("failed to open %s\n", "/dev/v4l-subdev2");
        return -1;
    }
    memset(&fmt, 0, sizeof(fmt));
    fmt.pad = 0;
    fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    fmt.format.code = V4L2_MBUS_FMT_YUYV8_2X8;
    
    fmt.format.width = capture->width;
    fmt.format.height = capture->height;
    fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    fmt.format.field = V4L2_FIELD_NONE;
 
    ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    if(ret) {
        printf("failed to set format on pad %x\n", fmt.pad);
    }
 
    memset(&fmt, 0, sizeof(fmt));
    fmt.pad = 1;
    fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    fmt.format.code = V4L2_MBUS_FMT_YUYV8_2X8;
    fmt.format.width = capture->width;
    fmt.format.height = capture->height;
    fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    fmt.format.field = V4L2_FIELD_NONE;
    ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    if(ret) {
        printf("failed to set format on pad %x\n", fmt.pad);
        return ret;
    }
 
    strcpy(subdev, "/dev/v4l-subdev8");
    ov2643_fd = open(subdev, O_RDWR);
    if(ov2643_fd == -1) {
        printf("failed to open %s\n", subdev);
        return -1;
    }
 
    memset(&fmt, 0, sizeof(fmt));
    fmt.pad = 0;
    fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    fmt.format.code = V4L2_MBUS_FMT_YUYV8_2X8;
    fmt.format.width = capture->width;
    fmt.format.height = capture->height;
 
    ret = ioctl(ov2643_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    if(ret) {
        printf("failed to set format on pad %x\n", fmt.pad);
        return ret;
    }
 
    printf("successfully format is set on all pad [WxH] - [%dx%d]\n",
            capture->width, capture->height);
    return ret;
}
#endif
 
static int  open_video_dev(const char *dev, int *capture_fd)//video device not opened
{
    /* Open the capture device */
    *capture_fd  = open((const char *) dev, O_RDWR);
    if (*capture_fd  <= 0) {
        printf("Cannot open = %s device\n", dev);
        return -1;
    }
    return 0;
}
 
static void close_video_dev(int capture_fd)
{
    /* close the device */
    close(capture_fd);
}
 
/*
 * Currently only return width and height.
 */
static int get_current_capture_format(int input_src, struct capture_dev *capture)
{
    struct v4l2_input input;
    v4l2_std_id std_id;
    struct v4l2_standard standard;
    int index;
 
 
    /* Get any active input */
    if (ioctl(capture->capture_fd, VIDIOC_G_INPUT, &index) < 0) {
        perror("VIDIOC_G_INPUT");
    }
    
    /* Enumerate input to get the name of the input detected */
    memset(&input, 0, sizeof(struct v4l2_input));
    input.index = index;
    if (ioctl(capture->capture_fd, VIDIOC_ENUMINPUT, &input) < 0) {
        perror("VIDIOC_ENUMINPUT");
    }
 
    printf("%s: Current Input: %s\n", CAPTURE_NAME, input.name);
 
    index = capture->tvp_input;
 
    if (ioctl(capture->capture_fd, VIDIOC_S_INPUT, &index) < 0) {
        perror("VIDIOC_S_INPUT");
    }
    memset(&input, 0, sizeof(struct v4l2_input));
    input.index = index;
    if (ioctl(capture->capture_fd, VIDIOC_ENUMINPUT, &input) < 0) {
        perror("VIDIOC_ENUMINPUT");
    }
    printf("%s: Input changed to: %s\n", CAPTURE_NAME, input.name);
 
 
    /* Detect the standard in the input detected */
    if (ioctl(capture->capture_fd, VIDIOC_QUERYSTD, &std_id) < 0) {
        perror("VIDIOC_QUERYSTD");
    }
 
    /* Get the standard*/
    if (ioctl(capture->capture_fd, VIDIOC_G_STD, &std_id) < 0) {
        /* Note when VIDIOC_ENUMSTD always returns EINVAL this
           is no video device or it falls under the USB exception,
           and VIDIOC_G_STD returning EINVAL is no error. */
        perror("VIDIOC_G_STD");
    }
 
    memset(&standard, 0, sizeof(standard));
    standard.index = 0;
 
    capture->width = IMG_WIDTH;
    capture->height = IMG_HEIGHT;
 
    return 0;
}
 
/*
 * This function initializes capture device. It selects an active input
 * and detects the standard on that input. It then allocates buffers in the
 * driver's memory space and mmaps them in the application space.
 */
static int capture_prepare_streaming(struct capture_dev *capture)
{
    struct v4l2_capability capability;
    struct v4l2_requestbuffers reqbuf;
    struct v4l2_buffer buf;
    struct v4l2_format *fmt = &capture->capture_fmt;
    int ret, i, j;
 
    /* Check if the device is capable of streaming */
    ret = ioctl(capture->capture_fd, VIDIOC_QUERYCAP, &capability);
    if (ret < 0) {
        perror("VIDIOC_QUERYCAP");
        return ret;
    }
    if (capability.capabilities & V4L2_CAP_STREAMING) {
        printf("%s: Capable of streaming\n", CAPTURE_NAME);
    } else {
        printf("%s: Not capable of streaming\n", CAPTURE_NAME);
        return -1;
    }
 
    fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    ret = ioctl(capture->capture_fd, VIDIOC_G_FMT, fmt);
    if (ret < 0) {
        perror("VIDIOC_G_FMT");
        return ret;
    }
 
    fmt->fmt.pix.width = capture->width;
    fmt->fmt.pix.height = capture->height;
    fmt->fmt.pix.pixelformat = DEF_PIX_FMT;
 
    fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    ret = ioctl(capture->capture_fd, VIDIOC_S_FMT, fmt);
    if (ret < 0) {
        perror("VIDIOC_S_FMT");
        return ret;
    }
 
    ret = ioctl(capture->capture_fd, VIDIOC_G_FMT, fmt);
    if (ret < 0) {
        perror("VIDIOC_G_FMT");
        return ret;
    }
 
    if (fmt->fmt.pix.pixelformat != DEF_PIX_FMT) {
        printf("%s: Requested pixel format not supported\n", CAPTURE_NAME);
        return -1;
    }
 
    /* Buffer allocation
     * Buffer can be allocated either from capture driver or
     * user pointer can be used
     */
    /* Request for MAX_BUFFER input buffers. As far as Physically contiguous
     * memory is available, driver can allocate as many buffers as
     * possible. If memory is not available, it returns number of
     * buffers it has allocated in count member of reqbuf.
     * HERE count = number of buffer to be allocated.
     * type = type of device for which buffers are to be allocated.
     * memory = type of the buffers requested i.e. driver allocated or
     * user pointer */
    reqbuf.count = capture->num_bufs;
    reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    reqbuf.memory = V4L2_MEMORY_MMAP;
    ret = ioctl(capture->capture_fd, VIDIOC_REQBUFS, &reqbuf);
    if (ret < 0) {
        perror("Cannot allocate memory");
        return ret;
    }
    /* Store the number of buffers actually allocated */
    capture->num_bufs = reqbuf.count;
    printf("%s: Number of requested buffers = %d\n", CAPTURE_NAME,
            capture->num_bufs);
 
    memset(&buf, 0, sizeof(buf));
 
    /* Mmap the buffers
     * To access driver allocated buffer in application space, they have
     * to be mmapped in the application space using mmap system call */
    for (i = 0; i < (capture->num_bufs); i++) {
        buf.type = reqbuf.type;
        buf.index = i;
        buf.memory = reqbuf.memory;
        ret = ioctl(capture->capture_fd, VIDIOC_QUERYBUF, &buf);
        if (ret < 0) {
            perror("VIDIOC_QUERYCAP");
            capture->num_bufs = i;
            goto ERROR;
        }
 
 
        capture_buff_info[i].length = buf.length;
        capture_buff_info[i].index = i;
        capture_buff_info[i].start = mmap(NULL, buf.length,
                PROT_READ | PROT_WRITE, MAP_SHARED, capture->capture_fd,
                buf.m.offset);
 
        if (capture_buff_info[i].start == MAP_FAILED) {
            printf("Cannot mmap = %d buffer\n", i);
            capture->num_bufs = i;
            goto ERROR;
        }
 
        memset((void *) capture_buff_info[i].start, 0x80,
                capture_buff_info[i].length);
        /* Enqueue buffers
         * Before starting streaming, all the buffers needs to be
         * en-queued in the driver incoming queue. These buffers will
         * be used by thedrive for storing captured frames. */
        ret = ioctl(capture->capture_fd, VIDIOC_QBUF, &buf);
        if (ret < 0) {
            perror("VIDIOC_QBUF");
            capture->num_bufs = i + 1;
            goto ERROR;
        }
    }
 
    printf("%s: Init done successfully\n\n", CAPTURE_NAME);
    return 0;
 
ERROR:
    for (j = 0; j < capture->num_bufs; j++)
        munmap(capture_buff_info[j].start,
                capture_buff_info[j].length);
    return -1;
}
 
/*
 * This function initializes display device. It sets output and standard for
 * LCD. These output and standard are same as those detected in capture device.
 * It, then, allocates buffers in the driver's memory space and mmaps them in
 * the application space
 */
static int display_prepare_streaming(struct display_dev *display)
{
    int ret, i, j;
    struct v4l2_requestbuffers reqbuf;
    struct v4l2_buffer buf;
    struct v4l2_capability capability;
    struct v4l2_control control;
    struct v4l2_format *fmt = &display->display_fmt;
 
    /* Open the video display device */
    display->display_fd = open((const char *) DISPLAY_DEVICE, O_RDWR);
    if (display->display_fd <= 0) {
        printf("Cannot open = %s device\n", DISPLAY_DEVICE);
        return -1;
    }
    printf("\n%s: Opened Channel\n", DISPLAY_NAME);
 
    /* Check if the device is capable of streaming */
    if (ioctl(display->display_fd, VIDIOC_QUERYCAP, &capability) < 0) {
        perror("VIDIOC_QUERYCAP");
        goto ERROR;
    }
 
    if (capability.capabilities & V4L2_CAP_STREAMING)
        printf("%s: Capable of streaming\n", DISPLAY_NAME);
    else {
        printf("%s: Not capable of streaming\n", DISPLAY_NAME);
        goto ERROR;
    }
 
    /* Rotate by 90 degree so that 480x640 resolution will become 640x480 */
 
    control.id = V4L2_CID_ROTATE;
    control.value = 0;
    ret = ioctl(display->display_fd, VIDIOC_S_CTRL, &control);
    if (ret < 0) {
        perror("VIDIOC_S_CTRL");
        goto ERROR;
    }
 
    /* Get the format */
    fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    ret = ioctl(display->display_fd, VIDIOC_G_FMT, fmt);
    if (ret < 0) {
        perror("VIDIOC_G_FMT");
        goto ERROR;
    }
 
    fmt->fmt.pix.width = display->width;
    fmt->fmt.pix.height = display->height;
    fmt->fmt.pix.pixelformat = DEF_PIX_FMT;
    fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    ret = ioctl(display->display_fd, VIDIOC_S_FMT, fmt);
    if (ret < 0) {
        perror("VIDIOC_S_FMT");
        goto ERROR;
    }
 
    ret = ioctl(display->display_fd, VIDIOC_G_FMT, fmt);
    if (ret < 0) {
        perror("VIDIOC_G_FMT");
        goto ERROR;
    }
 
        if (fmt->fmt.pix.pixelformat != DEF_PIX_FMT) {
            printf("%s: Requested pixel format not supported\n",
                    CAPTURE_NAME);
            goto ERROR;
        }
 
    /* Buffer allocation
     * Buffer can be allocated either from capture driver or
     * user pointer can be used
     */
    /* Request for MAX_BUFFER input buffers. As far as Physically contiguous
     * memory is available, driver can allocate as many buffers as
     * possible. If memory is not available, it returns number of
     * buffers it has allocated in count member of reqbuf.
     * HERE count = number of buffer to be allocated.
     * type = type of device for which buffers are to be allocated.
     * memory = type of the buffers requested i.e. driver allocated or
     * user pointer */
    reqbuf.count = display->num_bufs;
    reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    reqbuf.memory = V4L2_MEMORY_MMAP;
    ret = ioctl(display->display_fd, VIDIOC_REQBUFS, &reqbuf);
    if (ret < 0) {
        perror("Cannot allocate memory");
        goto ERROR;
    }
    /* Store the numbfer of buffers allocated */
    display->num_bufs = reqbuf.count;
    printf("%s: Number of requested buffers = %d\n", DISPLAY_NAME,
           display->num_bufs);
 
    memset(&buf, 0, sizeof(buf));
 
    /* Mmap the buffers
     * To access driver allocated buffer in application space, they have
     * to be mmapped in the application space using mmap system call */
    for (i = 0; i < display->num_bufs; i++) {
        /* Query physical address of the buffers */
        buf.type = reqbuf.type;
        buf.index = i;
        buf.memory = reqbuf.memory;
        ret = ioctl(display->display_fd, VIDIOC_QUERYBUF, &buf);
        if (ret < 0) {
            perror("VIDIOC_QUERYCAP");
            display->num_bufs = i;
            goto ERROR1;
        }
 
        /* Mmap the buffers in application space */
        display_buff_info[i].length = buf.length;
        display_buff_info[i].index =  i;
        display_buff_info[i].start = mmap(NULL, buf.length,
                PROT_READ | PROT_WRITE, MAP_SHARED, display->display_fd,
                buf.m.offset);
 
        if (display_buff_info[i].start == MAP_FAILED) {
            printf("Cannot mmap = %d buffer\n", i);
            display->num_bufs = i;
            goto ERROR1;
        }
        memset((void *) display_buff_info[i].start, 0x80,
               display_buff_info[i].length);
 
        /* Enqueue buffers
         * Before starting streaming, all the buffers needs to be
         * en-queued in the driver incoming queue. These buffers will
         * be used by thedrive for storing captured frames. */
        ret = ioctl(display->display_fd, VIDIOC_QBUF, &buf);
        if (ret < 0) {
            perror("VIDIOC_QBUF");
            display->num_bufs = i + 1;
            goto ERROR1;
        }
    }
    printf("%s: Init done successfully\n\n", DISPLAY_NAME);
    return 0;
 
ERROR1:
    for (j = 0; j < display->num_bufs; j++)
        munmap(display_buff_info[j].start,
            display_buff_info[j].length);
ERROR:
    close(display->display_fd);
    return -1;
}
 
static int timeval_subtract(struct timeval *result, struct timeval *x,
                             struct timeval *y)
{
    /* Perform the carry for the later subtraction by updating y.
     * */
    if (x->tv_usec < y->tv_usec) {
        int nsec = (y->tv_usec - x->tv_usec) /
            1000000 + 1;
        y->tv_usec -= 1000000 *    nsec;
        y->tv_sec += nsec;
    }
    if (x->tv_usec - y->tv_usec > 1000000) {
        int nsec = (x->tv_usec - y->tv_usec) /
            1000000;
        y->tv_usec += 1000000 * nsec;
        y->tv_sec -= nsec;
    }
 
    /* Compute the time remaining to wait.
       tv_usec is certainly positive. */
    result->tv_sec = x->tv_sec - y->tv_sec;
    result->tv_usec = x->tv_usec - y->tv_usec;
 
    /* Return 1 if result is
     * negative. */
    return x->tv_sec < y->tv_sec;
}
 
int main(int argc, char *argv[])
{
    int i = 0, ret = 0, a;
    unsigned int loop_cnt = MAXLOOPCOUNT;
    struct media_dev media;
    struct capture_dev capture;
    struct display_dev display;
    struct timeval before, after, result;
 
    memset(&media, 0, sizeof(struct media_dev));
    memset(&capture, 0, sizeof(struct capture_dev));
    memset(&display, 0, sizeof(struct display_dev));
 
    /* Setup default init for all devices */
    /* Media */
    media.input_source = 0;    
    /* Capture */
    capture.num_bufs = CAPTURE_MAX_BUFFER;
    /* Display */
    display.num_bufs = DISPLAY_MAX_BUFFER;
 
    capture.tvp_input = 0;
 
    for(i = 0; i < capture.num_bufs; i++) {
        capture_buff_info[i].start = NULL;
    }
    for(i = 0; i < display.num_bufs; i++) {
        display_buff_info[i].start = NULL;
    }
    /*
     * Initialization section
     * In case of Media-Controller compliant device: Setup Links
     * Initialize capture and display devices.
     * Here one capture channel is opened and input and standard is
     * detected on that channel.
     * Display channel is opened with the same standard that is detected at
     * capture channel.
     * */
#if defined (CONFIG_OMAP3530)
    /* Open the Media device */
    ret  = media_device_open(&media);
    if (ret < 0)
        return ret;
 
    ret = enumerate_all_entities(&media);
    if (ret < 0)
        goto err_0;
 
    /* Setup Links */
    ret = setup_media_links(&media);
    if (ret < 0)
        goto err_0;
 
    media_device_close(media.media_fd);
#endif
    /* Open the capture device */
    ret = open_video_dev((const char *)CAPTURE_DEVICE, &capture.capture_fd);
    if (ret < 0)
        goto err_1; //media device not opened
 
    ret = get_current_capture_format(media.input_source, &capture);
    if (ret < 0)
        goto err_1;
 
    /* Make width/height capture = display*/
    display.width = capture.width;
    display.height = capture.height;
 
#if defined (CONFIG_OMAP3530)
    /*
     * Now set the detected format at each pad
     */
    ret = set_subdev_format(&media, &capture);
    if (ret < 0)
        goto err_2;
#endif
    ret = capture_prepare_streaming(&capture);  // successfully runed  
    if(ret < 0)
        goto err_3;
 
    /* open display channel */
    ret = display_prepare_streaming(&display); //not exceuting
    if(ret < 0) {
        printf("Error in opening display device\n");
        goto err_4;
    }
 
    /* run section
     * STEP2:
     * Here display and capture channels are started for streaming. After
     * this capture device will start capture frames into enqueued
     * buffers and display device will start displaying buffers from
     * the qneueued buffers */
 
    /* Start Streaming. on display device */
    a = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    ret = ioctl(display.display_fd, VIDIOC_STREAMON, &a);
    printf("[%d]========display_ret_value========\n",ret);  //ret value [0] success
    if (ret < 0) {
        perror("VIDIOC_STREAMON");
        printf("[%d]========display_name========\n",ret);
        goto err_4;
    }
    printf("%s: Stream on...\n", DISPLAY_NAME);
    printf("========after display stream on========\n");
 
 
    /* Start Streaming. on capture device */
    a = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    ret = ioctl(capture.capture_fd, VIDIOC_STREAMON, &a);
    printf("[%d]========capture_ret_value========\n",ret); //ret value [-1] failed
    if (ret < 0) {
        perror("VIDIOC_STREAMON"); //error :Broken pipe
        printf("========after capture stream on========\n"); //error displayed
        goto err_4;
    }
    printf("%s: Stream on...\n", CAPTURE_NAME);// printed
 
    /* Set the display buffers for queuing and dqueueing operation */
    display.display_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    display.display_buf.index = 0;
    display.display_buf.memory = V4L2_MEMORY_MMAP;
    printf("==========display buffer for queuing and dequeuing==========");
 
    /* Set the capture buffers for queuing and dqueueing operation */
    capture.capture_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    capture.capture_buf.index = 0;
    capture.capture_buf.memory = V4L2_MEMORY_MMAP;
 
    printf("==========capture buffer for queuing and dequeuing==========");
    /* One buffer is dequeued from display and capture channels.
     * Capture buffer will be copied to display buffer.
     * All two buffers are put back to respective channels.
     * This sequence is repeated in loop.
     * After completion of this loop, channels are stopped.
     */
 
#if defined (FILE_WRITE)
    FILE * fd = NULL;
    fd = fopen("/home/yuv","w+b");
    if(NULL == fd)
    {     
        perror("open");
        printf("\n fopen() Error!!!\n");
        return 1;
    }     
    printf("\n File opened successfully through open()\n");
#endif
 
 
 
    gettimeofday(&before, NULL);
    for (i = 0; i < loop_cnt; i++) {
        int h;
        unsigned char *cap_ptr, *dis_ptr;
        /* Dequeue display buffer */
        ret = ioctl(display.display_fd, VIDIOC_DQBUF, &display.display_buf);
        if (ret < 0) {
            perror("VIDIOC_DQBUF");
            goto err_4;
        }
 
        /* Dequeue capture buffer */
        ret = ioctl(capture.capture_fd, VIDIOC_DQBUF, &capture.capture_buf);
        if (ret < 0) {
            perror("VIDIOC_DQBUF");
            goto err_4;
        }
 
        cap_ptr = (unsigned char*)capture_buff_info[capture.capture_buf.index].start;
        dis_ptr = (unsigned char*)display_buff_info[display.display_buf.index].start;
 
 
#if defined (FILE_WRITE)
        printf("writing to file...\n");
        if ((fwrite(cap_ptr, display.height * display.width * 2, 1, fd)) < 0)
        {
            perror("fwrite");
        }
#endif
 
 
 
        for (h = 0; h < display.height; h++) {
            memcpy(dis_ptr, cap_ptr, display.width * 2);
            cap_ptr += capture.width * 2;
            dis_ptr += display.width * 2;
        }
 
        ret = ioctl(capture.capture_fd, VIDIOC_QBUF, &capture.capture_buf);
        if (ret < 0) {
            perror("VIDIOC_QBUF");
            goto err_4;
        }
 
        ret = ioctl(display.display_fd, VIDIOC_QBUF, &display.display_buf);
        if (ret < 0) {
            perror("VIDIOC_QBUF");
            goto err_4;
        }
    }
    gettimeofday(&after, NULL);
 
    a = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    ret = ioctl(display.display_fd, VIDIOC_STREAMOFF, &a);
    if (ret < 0) {
        perror("VIDIOC_STREAMOFF");
        goto err_4;
    }
    printf("\n%s: Stream off!!\n", DISPLAY_NAME);
 
    a = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    ret = ioctl(capture.capture_fd, VIDIOC_STREAMOFF, &a);
    if (ret < 0) {
        perror("VIDIOC_STREAMOFF");
        goto err_4;
    }
    printf("%s: Stream off!!\n", CAPTURE_NAME);
 
    printf("\nLoopback Successful\n\n");
    printf("Timing Analysis:\n");
    printf("----------------\n");
    printf("Before Time:\t%lu %lu\n",before.tv_sec, before.tv_usec);
    printf("After Time:\t%lu %lu\n",after.tv_sec, after.tv_usec);
    timeval_subtract(&result, &after, &before);
    printf("Result Time:\t%ld %ld\n",result.tv_sec, result.tv_usec);
 
 
err_4:
    /* Un-map the buffers */
    for (i = 0; i < display.num_bufs; i++) {
        munmap(display_buff_info[i].start,
               display_buff_info[i].length);
        display_buff_info[i].start = NULL;
    }
 
    /* Close the file handle */
    close(display.display_fd);
err_3:
    /* Un-map the buffers */
    for (i = 0; i < capture.num_bufs; i++) {
        munmap(capture_buff_info[i].start,
               capture_buff_info[i].length);
        capture_buff_info[i].start = NULL;
    }
err_2:
    /* Close the file handle */
    close_video_dev(capture.capture_fd);
err_1:
#if defined (CONFIG_OMAP3530)
    /*TODO: Must reset the media before exiting here */
    reset_media_links(&media);
err_0:
    media_device_close(media.media_fd);
#endif
#if defined (FILE_WRITE)
    fclose(fd);
#endif
    return 0;
}

  • Hello,

    Can you just try using a simple GStreamer pipe to see if it works?  That way you can rule out if there is a problem with your source code.

    gst-launch-0.10 v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=320,height=240 ! ffmpegcolorspace ! fbdevsink

    Regards,

    Josh