V4L2 setting horizontal_flip results in "bar" artifacts - camera

Camera: OmniVision OV5645 (MIPI CSI-2 connection)
MCU: RK3399
Linux Kernel version: 4.4.189
Driver: v4 mainline
When I flip the camera horizontally using v4l2-ctl -d /dev/video0 --set-ctrl horizontal_flip=1, black vertical bar artifacts begin to appear at all the edges in the image.
Captured Images for comparison: flipped vs not flipped
Has anyone experienced a similar issue before? I'm not even sure where to begin debugging - is this due to the camera sensor or maybe the rkisp module onboard the rk3399 or something else? I don't have another MCU with a MIPI connection like a Raspberry Pi or something to test it on either.
Things I've tried that did not work:
Editing the OV5645 driver to flip the isp_mirror bit when the v4l2 horizontal_flip control is toggled. This not only did not fix the issue but resulted in a completely pink/purple image
Editing the OV5645 driver to set the default horizontal_flip to 1
Editing the initial i2c register values in the OV5645 driver to turn off binning
media-ctl topology dump:
Media controller API version 0.1.0
Media device information
------------------------
driver rkisp1
model rkisp1
serial
bus info
hw revision 0x0
driver version 0.0.0
Device topology
- entity 1: rkisp1-isp-subdev (4 pads, 6 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
[fmt:UYVY8_2X8/1920x1080 field:none
crop.bounds:(0,0)/1920x1080
crop:(0,0)/1920x1080]
<- "rkisp1_dmapath":0 []
<- "rockchip-mipi-dphy-rx":1 [ENABLED]
pad1: Sink
<- "rkisp1-input-params":0 [ENABLED]
pad2: Source
[fmt:YUYV8_2X8/1920x1080 field:none
crop.bounds:(0,0)/1920x1080
crop:(0,0)/1920x1080]
-> "rkisp1_selfpath":0 [ENABLED]
-> "rkisp1_mainpath":0 [ENABLED]
pad3: Source
-> "rkisp1-statistics":0 [ENABLED]
- entity 2: rkisp1_mainpath (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "rkisp1-isp-subdev":2 [ENABLED]
- entity 3: rkisp1_selfpath (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video1
pad0: Sink
<- "rkisp1-isp-subdev":2 [ENABLED]
- entity 4: rkisp1_dmapath (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video2
pad0: Source
-> "rkisp1-isp-subdev":0 []
- entity 5: rkisp1-statistics (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video3
pad0: Sink
<- "rkisp1-isp-subdev":3 [ENABLED]
- entity 6: rkisp1-input-params (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video4
pad0: Source
-> "rkisp1-isp-subdev":1 [ENABLED]
- entity 7: rockchip-mipi-dphy-rx (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Sink
[fmt:UYVY8_2X8/1920x1080 field:none]
<- "ov5645 2-003c":0 [ENABLED]
pad1: Source
[fmt:UYVY8_2X8/1920x1080 field:none]
-> "rkisp1-isp-subdev":0 [ENABLED]
- entity 8: ov5645 2-003c (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev2
pad0: Source
[fmt:UYVY8_2X8/1920x1080 field:none
crop:(0,0)/1920x1080]
-> "rockchip-mipi-dphy-rx":0 [ENABLED]

Related

How do I feed CD audio tracks into an ALSA-driven sound output device?

I'm using a USB CD/DVD drive without built-in sound decoder and controlling it via ALSA, which already works. The host is a Raspberry Pi 3B with the current Raspbian. Here is the corresponding config file:
pi#autoradio:/etc $ cat asound.conf
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 192000
format S32_LE
channels 2
}
bindings {
0 0
1 1
}
}
pcm.dsnooper {
type dsnoop
ipc_key 2048
ipc_perm 0666
slave
{
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
rate 192000
format S32_LE
channels 2
}
bindings {
0 0
1 1
}
}
pcm.duplex {
type asym
playback.pcm "dmixer"
capture.pcm "dsnooper"
}
pcm.!default {
type plug
slave.pcm "duplex"
}
ctl.!default {
type hw
card 0
}
To read the music from CD-DA, I'm gonna use the CDIO++ library. Its cd-info utility recognises both the drive, and the audio CD:
pi#autoradio:/etc $ cd-info
cd-info version 2.1.0 armv7l-unknown-linux-gnueabihf
CD location : /dev/cdrom
CD driver name: GNU/Linux
access mode: IOCTL
Vendor : MATSHITA
Model : CD-RW CW-8124
Revision : DA0D
Hardware : CD-ROM or DVD
Can eject : Yes
Can close tray : Yes
Can disable manual eject : Yes
Can select juke-box disc : No
Can set drive speed : No
Can read multiple sessions (e.g. PhotoCD) : Yes
Can hard reset device : Yes
Reading....
Can read Mode 2 Form 1 : Yes
Can read Mode 2 Form 2 : Yes
Can read (S)VCD (i.e. Mode 2 Form 1/2) : Yes
Can read C2 Errors : Yes
Can read IRSC : Yes
Can read Media Channel Number (or UPC) : Yes
Can play audio : Yes
Can read CD-DA : Yes
Can read CD-R : Yes
Can read CD-RW : Yes
Can read DVD-ROM : Yes
Writing....
Can write CD-RW : Yes
Can write DVD-R : No
Can write DVD-RAM : No
Can write DVD-RW : No
Can write DVD+RW : No
__________________________________
Disc mode is listed as: CD-DA
I've already got some code to send the PCM data to the sound card and some insight regarding the (rather poorly documented) CDIO API (I know that the readSectors() method is used for reading sound data from the CD sector after sector), but not really a clue on how to hand over the data from the CD-DA input to the ALSA output routine correctly.
Please nopte that mplayer is off-limits to me as this routine will be a part of a larger solution.
Any help would be greatly appreciated.
UPDATE: Does the different block size of an audio CD (2,352 bytes) and of the sound output (910 bytes, at least in my particular case) matter?
CD audio data is just two channels of little-endian 16-bit samples at 44.1 kHz.
If you output the data to the standard output, you can pipe it into your sound-playing program, or aplay:
./my-read-cdda | ./play 44100 2 99999
./my-read-cdda | aplay --file-type raw --format cd
If you want to do everything in a single program, replace the read(0, ...) with readSectors(). (The buffer size does not need to have any relation with ALSA's period size or buffer size.)

ALSA - setting input volume for line in command line - input not recognized but available for programs

I cant see the input device in alsamixer on the usb board, but it is listed as I do arecord -L (also why is it listing the 2nd sound card by default ?)
arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: CODEC [USB Audio CODEC], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I can see many informations but I cant figure from man, how to change the level of the line input in command line nor in the gui
amixer info
Card default 'CODEC'/'Burr-Brown from TI USB Audio CODEC at usb-3f980000.usb-1.3, full speed'
Mixer name : 'USB Mixer'
Components : 'USB08bb:2902'
Controls : 4
Simple ctrls : 1
amixer contents
numid=3,iface=MIXER,name='PCM Playback Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=4,iface=MIXER,name='PCM Playback Volume'
; type=INTEGER,access=rw---R--,values=2,min=0,max=128,step=0
: values=128,128
| dBminmax-min=-128.00dB,max=0.00dB
numid=2,iface=PCM,name='Capture Channel Map'
; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
: values=0,0
| container
| chmap-fixed=FL,FR
| chmap-fixed=MONO
numid=1,iface=PCM,name='Playback Channel Map'
; type=INTEGER,access=r----R--,values=2,min=0,max=36,step=0
: values=0,0
| container
| chmap-fixed=FL,FR
| chmap-fixed=MONO
I am actualy not sure about how to achieve this since many people say thousands of different thing
here I try to set the volume in a clumsy way, and it does not work :
amixer -c 1 sset numid=2 0
amixer: Unable to find simple control 'numid=2',0
amixer -c 1 cset numid=2 0
amixer: Control hw:1 element write error: Operation not permitted
sudo amixer -c 1 cset numid=2 0
amixer: Control hw:1 element write error: Operation not permitted
amixer does not list any record device although I can clearly record audio with audacity or puredata
amixer -c 1
Simple mixer control 'PCM',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 128
Mono:
Front Left: Playback 128 [100%] [0.00dB] [on]
Front Right: Playback 128 [100%] [0.00dB] [on]
amixer -c 0
Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback -10239 - 400
Mono: Playback 0 [96%] [0.00dB] [on]
please help me out, this makes no sens at all to me
thanks guys
amixer and alsamixer shows those mixer controls that the hardware actually has.
As figure 31 in the PCM2902 datasheet shows, this device indeed has no mechanism to change the capture volume:
It might be possible to add a softvol plugin, but it would be easier to just use PulseAudio.

Can't debug my micro

Since I uploaded my stm32cubef1 firmware version up to 1.6.0, I can't debug anymore my board. I'm using SWSTM32 and ST-LINK/V2.
Once I press the "play" like button, when I try to stop it a Windows opens and it says:
"No source available for "dt_TPS()at 0x20000004"
where dt_TPS is one of my variables.
In the window at the bottom of the page I read this:
Open On-Chip Debugger 0.10.0-dev-00302-gc211ca5-dirty (2017-07-03-10:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_assert_srst
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : clock speed 1000 kHz
Info : STLINK v2 JTAG v28 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : vid/pid are not identical: 0x0483/0x374B 0x0483/0x3748
Info : using stlink api v2
Info : Target voltage: 3.239921
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : STM32F105R8Tx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
STM32F105R8Tx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x200001e0 msp: 0x20005000
Info : device id = 0x10016418
Info : flash size = 64kbytes
STM32F105R8Tx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x200001e0 msp: 0x20005000
STM32F105R8Tx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x200001e0 msp: 0x20005000
Info : Padding image section 0 with 4 bytes
STM32F105R8Tx.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000003a msp: 0x20005000
STM32F105R8Tx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x200001e0 msp: 0x20005000
Error: address + size wrapped(0xffffffff, 0x00000004)
Error: address + size wrapped(0xffffffff, 0x00000002)
Error: address + size wrapped(0xffffffff, 0x00000004)
Error: address + size wrapped(0xffffffff, 0x00000002)
Other infos: my current toolchain is: AC6 STM32 MCU GCC, current builder: Gnu Make Builder and the micro I used is STM32F105R8T6
Does anyone know what's going on?
You appear to be executing code from SRAM rather then flash. That is unusual, and possibly not intentional.
The processor will execute from SRAM on reset when the BOOT0 and BOOT1 pins are both high. Normally you load and execute code from flash (BOOT0 low, BOOT1 don't care) - your board may have jumpers for boot mode selection.

Configuring MPD with an 5.1 external surround sound card

I've read tons of threads about this, but i cant figure it out.
So i have a MPD server running on Raspbian, with an external sound card attached to it. Music works fine trough mpd with the 2 channels, but not for 6 channels.
Also i am confused what is the task of all programs involved.
So there's alsa. I Have tried to change the /etc/asound.conf to many different configurations. Like:
pcm.!default {
type route
slave.pcm surround51
slave.channels 6
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
ttable.0.5 0.5
ttable.1.5 0.5
}
But it did not work. My current settings are:
pcm.!default {
type hw
card 2
device 0
}
ctl.!default {
type hw
card 2 #If you want to set HDMI as output ,turn 0 to 1.
}
Then there is pulse audio. I am not sure if the function of both programs overlap, or if you should use them together. To the pulseaudio config file /etc/pulse/daemon.conf i have edited the following line:
default-sample-channels = 6
Furthermore i have added the following line to /etc/pulse/default.pa
set-card-profile 2 output:analog-surround-51
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 # IP of l$
But i am not sure it has any effect at all.
So last there is mpd configuration which I had configure at ~/.mpd/mpd.conf
audio_output {
type "alsa"
name "My ALSA Device"
mixer_type "software"
mixer_control "PCM"
}
If i change alsa to pulse i cant hear sound. Furthermore, the command speaker-test -c 6 -t wav
IS working for 6 channels. Since mpd is configured with alsa, and speaker-test does work, i guess that it is pulseaudio that creates the surround sound. But how can i configure MPD to work with surround sound?
Does anyone have any idea? Any help is much appreciated!
Here is the ouput of aplay -l
xcb_connection_has_error() returned true
card 0: sunxicodec [sunxi-CODEC], device 0: M1 PCM [sunxi PCM]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sunxisndhdmi [sunxi-sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: Device [USB Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
and
Update:
If i play sound as the mpd user it also works with surround sound
sudo -u mpd speaker-test -c 6 -t wav
Eventually this worked for me:
pcm.ch51 {
slave sl2
#slave.channels 6
type route
ttable.0.0 1
ttable.1.1 1
ttable.0.2 1
ttable.1.3 1
ttable.0.4 0.5
ttable.1.4 0.5
ttable.0.5 0.5
ttable.1.5 0.5
}
pcm_slave.sl2 {
channels 6
pcm "hw:1,0"
}
In ~/.asoundrc. The table thing duplicates sound to other speakers so all 5+1 speakers are used. The pcm "hw:1,0" selects my external usb sound card.
Additionally in ~/.mpd/mpd.conf
audio_output {
type "alsa"
name "My ALSA Device"
channels "6"
device "ch51"
You select the device specified in asound.rc

Nand partitioning in u-boot

I am working on an Embedded ARM9 development board. In that i want rearrange my nand partitions. Can anybody tell me how to do that ?
In my u-boot shell if i give the command mtdparts which gives following information .
Boardcon> mtdparts
device nand0 <nandflash0>, # parts = 7
#: name size offset mask_flags
0: bios 0x00040000 0x00000000 0
1: params 0x00020000 0x00040000 0
2: toc 0x00020000 0x00060000 0
3: eboot 0x00080000 0x00080000 0
4: logo 0x00100000 0x00100000 0
5: kernel 0x00200000 0x00200000 0
6: root 0x03c00000 0x00400000 0
active partition: nand0,0 - (bios) 0x00040000 # 0x00000000
defaults:
mtdids : nand0=nandflash0
mtdparts: mtdparts=nandflash0:256k#0(bios),128k(params),128k(toc),512k(eboot),1024k(logo),2m(kernel),-(root)
Kernel boot message shows the following :
Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "Boardcon_Board_uboot"
0x000000200000-0x000000400000 : "Boardcon_Board_kernel"
0x000000400000-0x000003ff8000 : "Boardcon_Board_yaffs2"
Anybody can please explain me what is the relation between both these messages . And which one either kernel or u-boot is responsible for creating partions on nand flash?. As for as i know kernel is not creating partitions on each boot but why the message "Creating 3 MTD partitions"?
For flash devices, either NAND or NOR, there is no partition table on the device itself. That is, you can't read the device in a flash reader and find some table that indicates how many partitions are on the device and where each partition begins and ends. There is only an undifferentiated sequence of blocks. This is a fundamental difference between MTD flash devices and devices such as disks or FTL devices such as MMC.
The partitioning of the flash device is therefore in the eyes of the beholder, that is, either U-Boot or the kernel, and the partitions are "created" when beholder runs. That's why you see the message Creating 3 MTD partitions. It reflects the fact that the flash partitions really only exist in the MTD system of the running kernel, not on the flash device itself.
This leads to a situation in which U-Boot and the kernel can have different definitions of the flash partitions, which is apparently what has happened in the case of the OP.
In U-Boot, you define the flash partitions in the mtdparts environment variable. In the Linux kernel, the flash partitions are defined in the following places:
In older kernels (e.g. 2.6.35 for i.MX28) the flash partitioning could be hard-coded in gpmi-nfc-mil.c or other driver source code. (what a bummer!).
In the newer mainline kernels with device tree support, you can define the MTD paritions in the device tree
In the newer kernels there is usually support for kernel command line partition definition using a command line like root=/dev/mmcblk0p2 rootwait console=ttyS2,115200 mtdparts=nand:6656k(all),1m(squash),-(jffs2)
The type of partitioning support that you have in the kernel therefore depends on the type of flash you are using, whether it's driver supports kernel command line parsing and whether your kernel has device tree support.
In any event, there is an inherent risk of conflict between the U-Boot and kernel partitioning of the flash. Therefore, my recommendation is to define the flash partitions in the U-Boot mtdparts variable and to pass this to the kernel in the U-Boot kernel command line, assuming that your kernel support this option.
you can set the mtdparts environment variable to do so in uboot, and the kernel only use this if you pass this in kernel boot commandline, or else it'll default to the nand partition structure in the kernel source code for your platform, which in this case the 3 MTD partition default.