Feonx
Posts: 1
Joined: Sat Jan 04, 2020 11:05 pm

Lusya HDMI interface to CSI-2 (TC358743XBG)

Sat Jan 04, 2020 11:28 pm

Hi,

Question context:
  • Raspberry Pi 3B (RPi)
  • Lusya HDMI interface with chip: TC358743XBG
    https://www.aliexpress.com/item/4000152180240.html
  • PC LED screen
  • Laptop (mac book)
  • Camera module is connected to the RPi via the CSI-2 connector.
  • Laptop is connected to the camera module input via HDMI.
  • RPi HDMI output is connected to the PC LED screen.
Target
I would like to make the RPi as "man-in-the-middle" between the laptop input and the PC LED screen output. So that I can capture the screen images while watching the Laptop output on the PC LED screen.

I have got it working
Thanks to this wonderful PiCamera library I can get this to work by:

Code: Select all

from time import sleep
from picamera import PiCamera

camera = PiCamera()
camera.start_preview()
sleep(2)
for filename in camera.capture_continuous('image.jpg'):
    sleep(1)
Issue
When the PiCamera script (above) is running and I disconnect the HDMI connection by shutting down the laptop, the script hangs at camera.capture_continuous forever.

When I run the PiCamera script (above) and the HDMI is disconnected at the start it will try to connect which takes about 10 seconds and then throws an exception.

This is not unexpected behavior, but I would like to be able to check whether the Laptop is connected to the camera module input before starting the PiCamera instance and before starting an image capture, so I can act on it.

The ideal situation would be to check whether the Laptop is connected and then start the capture script.

What did I try to solve this?

1. I found the following forum topic:
https://www.raspberrypi.org/forums/view ... hp?t=46113
They say you can check the connection by running "opt/vc/bin/vcgencmd get_camera". This is not a solution for my case because it checks the camera module connection on the RPi. It will always return: "supported=1 detected=1" whether the HDMI input is connected or disconnected.

2. I tried to search the dmesg output to see any changes.

3. I searched the source of PiCamera and read the docs about MMAL. I tried to read the camera inputs like:

Code: Select all

from picamera import mmal, mmalobj as mo
	camera = mo.MMALCamera()
	preview = mo.MMALRenderer()

	print(camera.outputs[0])
	print(preview.inputs[0])
I tried:
from picamera import PiCamera
from time import sleep

while True:
	if check() == False:
		time.sleep(1)
		print("Not connected stil checking...")
	else:
		print("Connected")		

def check():
	try:
		camera = PiCamera()
	expect:
		return False
	return True
but this is not really efficient and it can take a long time for the PiCamera instance to respond (10 seconds) when there is no HDMI connection

4. I tried to find a way to configure the PiCamera class so that I can control the waiting time of 10 seconds and reduce it to 2 (changing the connection timeout of some kind).

5. I tried to run the camera = PiCamera() part in a multiprocessing process and when the process does not respond within 2 seconds it would kill the process. This somewhat works but the PiCamera instance is not disposed correctly and create some side effects.

6. I asked in the Github of PiCamera library help:
https://github.com/waveform80/picamera/issues/605

Because of the Github help from user "6by9":
6.1 I tried to search for some datasheets / circuit diagrams of the Lusya board but without any result
6.2 I have checked to see if there are any voltage differences between the pins when the cable is connected or disconnected with my multimeter, also without any result.

Question:
It seems that I need some hardware knowledge to perform an HDMI cable detection but how?

I hope someone can help me, I cannot figure it out. I'm currently at a dead end.

Thanks in advance!

Return to “Graphics, sound and multimedia”