FC2カウンター FPGAの部屋 ZYBO Z7-20 の PYNQ 2.7 上で Jupyter Notebook に画像を表示する2
fc2ブログ

FPGAやCPLDの話題やFPGA用のツールの話題などです。 マニアックです。 日記も書きます。

FPGAの部屋

FPGAの部屋の有用と思われるコンテンツのまとめサイトを作りました。Xilinx ISEの初心者の方には、FPGAリテラシーおよびチュートリアルのページをお勧めいたします。

ZYBO Z7-20 の PYNQ 2.7 上で Jupyter Notebook に画像を表示する2

ZYBO Z7-20 の PYNQ 2.7 上で Jupyter Notebook に画像を表示する1”の続き。

Jupyter Notebook にカメラ画像を表示しようということで、前回は、cam_disp_bd ブロック・デザインに axis2DMA IP を追加した。今回は、前回作成したビットストリームと hwh ファイルを ZYBO Z7-20 の PYNQ LInux 上にアップロードして、Jupyter Notebook を起動して動作を確認したところ、Jupyter Notebook に表示されたカメラ画像が真っ黒だった。axis2DMA IP に AXI4-Stream データが渡っていないのだろうか?

ZYBO Z7-20 で PYNQ を起動し、ssh からログインして、Jupyter Notebook を起動した。
sudo jupyter notebook --allow-root

ホスト・パソコンのブラウザで http://192.168.3.35:9090/tree/my_project を表示した。

cam_disp.bit と cam_disp.hwh を削除した。

cam_disp/cam_disp.runs/impl_1/cam_disp_bd_wrapper.bit と cam_disp/cam_disp.gen/sources_1/bd/cam_disp_bd/hw_handoff/cam_disp_bd.hwh をアップロードした。

cam_disp_bd_wrapper.bit と cam_disp_bd.hwh の名前を cam_disp.bit と cam_disp.hwh に変更した。

Jupyter Notebook ファイルの cam_disp.ipynb ファイルに axis2DMA IP の制御用コードと Jupyter Notebook にカメラ画像を表示するコードを追加した。

cam_disp.ipynb を実行していったところ、真っ黒な画像が表示された。
ZYBO_Z7_PYNQ_198_220821.png

なお、カメラ画像はディスプレイに表示されている。このカメラ - ディスプレイ表示パスに問題は無いようだ。

cam_disp.ipynb の python コードを貼っておく。

# cam_disp.py
# 2022/08/05 by marsee
# 2022/08/14 : Added Sobel filter.

from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from pynq import allocate, Overlay
import time

# Download bitstream
cam_disp = Overlay("./cam_disp.bit")

# Generate an instance for each IP
vflip_dmaw = cam_disp.vflip_dma_write_0
dma2axis3 = cam_disp.DMA2axis_3buf_0
paracam_inf = cam_disp.paracam_inf_axis_0
bmpd_cont = cam_disp.btimap_disp_cont_axis_0
cam_iic = cam_disp.cam_iic_0
sobel = cam_disp.sobel_axis_RGB24_0
axis2dma = cam_disp.axis2DMA_0

def cam_i2c_init(cam_iic):
    cam_iic.write(0x100, 0x2)   # reset tx fifo ,address is 0x100, i2c_control_reg
    cam_iic.write(0x100, 0x1)   # enable i2c

def cam_i2x_write_sync():
    time.sleep(0.001) # 1ms wait

def cam_i2c_write(cam_iic, device_addr, write_addr, write_data):
    cam_iic.write(0x108, bin(0x100 | (device_addr & 0xfe)))   # Slave IIC Write Address, address is 0x108, i2c_tx_fifo
    cam_iic.write(0x108, bin((write_addr >> 8) & 0xff))      # address upper byte
    cam_iic.write(0x108, bin(write_addr & 0xff)) # address lower byte
    cam_iic.write(0x108, bin(0x200 | (write_data & 0xff)))   # data
    cam_i2x_write_sync()

def cam_reg_set(cam_iic, device_addr):
    cam_i2c_write(cam_iic, device_addr, 0x3103, 0x93)
    cam_i2c_write(cam_iic, device_addr, 0x3008, 0x82)
    cam_i2c_write(cam_iic, device_addr, 0x3017, 0x7f)
    cam_i2c_write(cam_iic, device_addr, 0x3018, 0xfc)
    cam_i2c_write(cam_iic, device_addr, 0x3810, 0xc2)
    cam_i2c_write(cam_iic, device_addr, 0x3615, 0xf0)
    cam_i2c_write(cam_iic, device_addr, 0x3000, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3001, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3002, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3003, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3000, 0xf8)
    cam_i2c_write(cam_iic, device_addr, 0x3001, 0x48)
    cam_i2c_write(cam_iic, device_addr, 0x3002, 0x5c)
    cam_i2c_write(cam_iic, device_addr, 0x3003, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x3004, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x3005, 0xb7)
    cam_i2c_write(cam_iic, device_addr, 0x3006, 0x43)
    cam_i2c_write(cam_iic, device_addr, 0x3007, 0x37)
    cam_i2c_write(cam_iic, device_addr, 0x3011, 0x08) # 0x08 - 15fps, 0x10 - 30fps
    cam_i2c_write(cam_iic, device_addr, 0x3010, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x460c, 0x22)
    cam_i2c_write(cam_iic, device_addr, 0x3815, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x370d, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x370c, 0xa0)
    cam_i2c_write(cam_iic, device_addr, 0x3602, 0xfc)
    cam_i2c_write(cam_iic, device_addr, 0x3612, 0xff)
    cam_i2c_write(cam_iic, device_addr, 0x3634, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x3613, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3605, 0x7c)
    cam_i2c_write(cam_iic, device_addr, 0x3621, 0x09)
    cam_i2c_write(cam_iic, device_addr, 0x3622, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3604, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x3603, 0xa7)
    cam_i2c_write(cam_iic, device_addr, 0x3603, 0x27)
    cam_i2c_write(cam_iic, device_addr, 0x4000, 0x21)
    cam_i2c_write(cam_iic, device_addr, 0x401d, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x3600, 0x54)
    cam_i2c_write(cam_iic, device_addr, 0x3605, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x3606, 0x3f)
    cam_i2c_write(cam_iic, device_addr, 0x3c01, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5000, 0x4f)
    cam_i2c_write(cam_iic, device_addr, 0x5020, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x5181, 0x79)
    cam_i2c_write(cam_iic, device_addr, 0x5182, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5185, 0x22)
    cam_i2c_write(cam_iic, device_addr, 0x5197, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x5001, 0xff)
    cam_i2c_write(cam_iic, device_addr, 0x5500, 0x0a)
    cam_i2c_write(cam_iic, device_addr, 0x5504, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5505, 0x7f)
    cam_i2c_write(cam_iic, device_addr, 0x5080, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x300e, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x4610, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x471d, 0x05)
    cam_i2c_write(cam_iic, device_addr, 0x4708, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x3710, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x3632, 0x41)
    cam_i2c_write(cam_iic, device_addr, 0x3702, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x3620, 0x37)
    cam_i2c_write(cam_iic, device_addr, 0x3631, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x3808, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x3809, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x380a, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x380b, 0xe0)
    cam_i2c_write(cam_iic, device_addr, 0x380e, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x380f, 0xd0)
    cam_i2c_write(cam_iic, device_addr, 0x501f, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5000, 0x4f)
    cam_i2c_write(cam_iic, device_addr, 0x4300, 0x61) # RGB565
    cam_i2c_write(cam_iic, device_addr, 0x3503, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x3501, 0x73)
    cam_i2c_write(cam_iic, device_addr, 0x3502, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x350b, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3503, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x3824, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x3501, 0x1e)
    cam_i2c_write(cam_iic, device_addr, 0x3502, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x350b, 0x7f)
    cam_i2c_write(cam_iic, device_addr, 0x380c, 0x0c)
    cam_i2c_write(cam_iic, device_addr, 0x380d, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x380e, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x380f, 0xe8)
    cam_i2c_write(cam_iic, device_addr, 0x3a0d, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x3a0e, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x3818, 0xc1)
    cam_i2c_write(cam_iic, device_addr, 0x3705, 0xdb)
    cam_i2c_write(cam_iic, device_addr, 0x370a, 0x81)
    cam_i2c_write(cam_iic, device_addr, 0x3801, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x3621, 0xc7)
    cam_i2c_write(cam_iic, device_addr, 0x3801, 0x50)
    cam_i2c_write(cam_iic, device_addr, 0x3803, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x3827, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x3810, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x3804, 0x05)
    cam_i2c_write(cam_iic, device_addr, 0x3805, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5682, 0x05)
    cam_i2c_write(cam_iic, device_addr, 0x5683, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3806, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x3807, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x5686, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x5687, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x3a00, 0x78)
    cam_i2c_write(cam_iic, device_addr, 0x3a1a, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x3a13, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x3a18, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3a19, 0x7c)
    cam_i2c_write(cam_iic, device_addr, 0x3a08, 0x12)
    cam_i2c_write(cam_iic, device_addr, 0x3a09, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x3a0a, 0x0f)
    cam_i2c_write(cam_iic, device_addr, 0x3a0b, 0xa0)
    cam_i2c_write(cam_iic, device_addr, 0x3004, 0xff)
    cam_i2c_write(cam_iic, device_addr, 0x350c, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x350d, 0xd0)
    cam_i2c_write(cam_iic, device_addr, 0x3500, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3501, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3502, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x350a, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x350b, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3503, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x528a, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x528b, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x528c, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x528d, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x528e, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x528f, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5290, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5292, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5293, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5294, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5295, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5296, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5297, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5298, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5299, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x529a, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529b, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x529c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529d, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x529e, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529f, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x3a0f, 0x3c)
    cam_i2c_write(cam_iic, device_addr, 0x3a10, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x3a1b, 0x3c)
    cam_i2c_write(cam_iic, device_addr, 0x3a1e, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x3a11, 0x70)
    cam_i2c_write(cam_iic, device_addr, 0x3a1f, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x3030, 0x0b)
    cam_i2c_write(cam_iic, device_addr, 0x3a02, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3a03, 0x7d)
    cam_i2c_write(cam_iic, device_addr, 0x3a04, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3a14, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3a15, 0x7d)
    cam_i2c_write(cam_iic, device_addr, 0x3a16, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3a00, 0x78)
    cam_i2c_write(cam_iic, device_addr, 0x3a08, 0x09)
    cam_i2c_write(cam_iic, device_addr, 0x3a09, 0x60)
    cam_i2c_write(cam_iic, device_addr, 0x3a0a, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x3a0b, 0xd0)
    cam_i2c_write(cam_iic, device_addr, 0x3a0d, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x3a0e, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x5193, 0x70)
    cam_i2c_write(cam_iic, device_addr, 0x3620, 0x57)
    cam_i2c_write(cam_iic, device_addr, 0x3703, 0x98)
    cam_i2c_write(cam_iic, device_addr, 0x3704, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x589b, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x589a, 0xc5)
    cam_i2c_write(cam_iic, device_addr, 0x528a, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x528b, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x528c, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x528d, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x528e, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x528f, 0x28)
    cam_i2c_write(cam_iic, device_addr, 0x5290, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5292, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5293, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5294, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5295, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5296, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5297, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5298, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5299, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x529a, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529b, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x529c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529d, 0x28)
    cam_i2c_write(cam_iic, device_addr, 0x529e, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529f, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5282, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5300, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5301, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5302, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5303, 0x7c)
    cam_i2c_write(cam_iic, device_addr, 0x530c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x530d, 0x0c)
    cam_i2c_write(cam_iic, device_addr, 0x530e, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x530f, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5310, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5311, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5308, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5309, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x5304, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5305, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5306, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5307, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5314, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5315, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5319, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5316, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5317, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5318, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5380, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x5381, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5382, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5383, 0x4e)
    cam_i2c_write(cam_iic, device_addr, 0x5384, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5385, 0x0f)
    cam_i2c_write(cam_iic, device_addr, 0x5386, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5387, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5388, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x5389, 0x15)
    cam_i2c_write(cam_iic, device_addr, 0x538a, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538b, 0x31)
    cam_i2c_write(cam_iic, device_addr, 0x538c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538d, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538e, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538f, 0x0f)
    cam_i2c_write(cam_iic, device_addr, 0x5390, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5391, 0xab)
    cam_i2c_write(cam_iic, device_addr, 0x5392, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5393, 0xa2)
    cam_i2c_write(cam_iic, device_addr, 0x5394, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5480, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5481, 0x21)
    cam_i2c_write(cam_iic, device_addr, 0x5482, 0x36)
    cam_i2c_write(cam_iic, device_addr, 0x5483, 0x57)
    cam_i2c_write(cam_iic, device_addr, 0x5484, 0x65)
    cam_i2c_write(cam_iic, device_addr, 0x5485, 0x71)
    cam_i2c_write(cam_iic, device_addr, 0x5486, 0x7d)
    cam_i2c_write(cam_iic, device_addr, 0x5487, 0x87)
    cam_i2c_write(cam_iic, device_addr, 0x5488, 0x91)
    cam_i2c_write(cam_iic, device_addr, 0x5489, 0x9a)
    cam_i2c_write(cam_iic, device_addr, 0x548a, 0xaa)
    cam_i2c_write(cam_iic, device_addr, 0x548b, 0xb8)
    cam_i2c_write(cam_iic, device_addr, 0x548c, 0xcd)
    cam_i2c_write(cam_iic, device_addr, 0x548d, 0xdd)
    cam_i2c_write(cam_iic, device_addr, 0x548e, 0xea)
    cam_i2c_write(cam_iic, device_addr, 0x548f, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5490, 0x05)
    cam_i2c_write(cam_iic, device_addr, 0x5491, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5492, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x5493, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5494, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x5495, 0x60)
    cam_i2c_write(cam_iic, device_addr, 0x5496, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5497, 0xb8)
    cam_i2c_write(cam_iic, device_addr, 0x5498, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5499, 0x86)
    cam_i2c_write(cam_iic, device_addr, 0x549a, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x549b, 0x5b)
    cam_i2c_write(cam_iic, device_addr, 0x549c, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x549d, 0x3b)
    cam_i2c_write(cam_iic, device_addr, 0x549e, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x549f, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x54a0, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x54a1, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x54a2, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54a3, 0xed)
    cam_i2c_write(cam_iic, device_addr, 0x54a4, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54a5, 0xc5)
    cam_i2c_write(cam_iic, device_addr, 0x54a6, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54a7, 0xa5)
    cam_i2c_write(cam_iic, device_addr, 0x54a8, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54a9, 0x6c)
    cam_i2c_write(cam_iic, device_addr, 0x54aa, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54ab, 0x41)
    cam_i2c_write(cam_iic, device_addr, 0x54ac, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54ad, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x54ae, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x54af, 0x16)
    cam_i2c_write(cam_iic, device_addr, 0x3406, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5192, 0x04) # 0x04
    cam_i2c_write(cam_iic, device_addr, 0x5191, 0xf8) # 0xf8
    cam_i2c_write(cam_iic, device_addr, 0x5193, 0x70)
    cam_i2c_write(cam_iic, device_addr, 0x5194, 0xf0)
    cam_i2c_write(cam_iic, device_addr, 0x5195, 0xf0)
    cam_i2c_write(cam_iic, device_addr, 0x518d, 0x3d)
    cam_i2c_write(cam_iic, device_addr, 0x518f, 0x54)
    cam_i2c_write(cam_iic, device_addr, 0x518e, 0x3d)
    cam_i2c_write(cam_iic, device_addr, 0x5190, 0x54)
    cam_i2c_write(cam_iic, device_addr, 0x518b, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x518c, 0xbd)
    cam_i2c_write(cam_iic, device_addr, 0x5187, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x5188, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x5189, 0x6e)
    cam_i2c_write(cam_iic, device_addr, 0x518a, 0x68)
    cam_i2c_write(cam_iic, device_addr, 0x5186, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x5181, 0x50)
    cam_i2c_write(cam_iic, device_addr, 0x5184, 0x25)
    cam_i2c_write(cam_iic, device_addr, 0x5182, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x5183, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5184, 0x25)
    cam_i2c_write(cam_iic, device_addr, 0x5185, 0x24)
    cam_i2c_write(cam_iic, device_addr, 0x5025, 0x82)
    cam_i2c_write(cam_iic, device_addr, 0x5583, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x5584, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x5580, 0x02) # 0x02
    cam_i2c_write(cam_iic, device_addr, 0x3633, 0x07)
    cam_i2c_write(cam_iic, device_addr, 0x3702, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x3703, 0xb2)
    cam_i2c_write(cam_iic, device_addr, 0x3704, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x370b, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x370d, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x3620, 0x52)
    cam_i2c_write(cam_iic, device_addr, 0x3c00, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x5001, 0xFF)
    cam_i2c_write(cam_iic, device_addr, 0x5282, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5300, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5301, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5302, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5303, 0x7c)
    cam_i2c_write(cam_iic, device_addr, 0x530c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x530d, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x530e, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x530f, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5310, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5311, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5308, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5309, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x5304, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5305, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5306, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5307, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5314, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5315, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5319, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5316, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5317, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5318, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5500, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5502, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5503, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x5504, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5505, 0x7f)
    cam_i2c_write(cam_iic, device_addr, 0x5025, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5300, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5301, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5302, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5303, 0x7c)
    cam_i2c_write(cam_iic, device_addr, 0x530c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x530d, 0x0c)
    cam_i2c_write(cam_iic, device_addr, 0x530e, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x530f, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5310, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5311, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5308, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5309, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x5304, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5305, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5306, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5307, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5314, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5315, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x5319, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5316, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5317, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5318, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5380, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x5381, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5382, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5383, 0x1f)
    cam_i2c_write(cam_iic, device_addr, 0x5384, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5385, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x5386, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5387, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5388, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5389, 0xE1)
    cam_i2c_write(cam_iic, device_addr, 0x538A, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538B, 0x2B)
    cam_i2c_write(cam_iic, device_addr, 0x538C, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538D, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538E, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x538F, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5390, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5391, 0xB3)
    cam_i2c_write(cam_iic, device_addr, 0x5392, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5393, 0xA6)
    cam_i2c_write(cam_iic, device_addr, 0x5394, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5480, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5481, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x5482, 0x2a)
    cam_i2c_write(cam_iic, device_addr, 0x5483, 0x49)
    cam_i2c_write(cam_iic, device_addr, 0x5484, 0x56)
    cam_i2c_write(cam_iic, device_addr, 0x5485, 0x62)
    cam_i2c_write(cam_iic, device_addr, 0x5486, 0x6c)
    cam_i2c_write(cam_iic, device_addr, 0x5487, 0x76)
    cam_i2c_write(cam_iic, device_addr, 0x5488, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x5489, 0x88)
    cam_i2c_write(cam_iic, device_addr, 0x548a, 0x96)
    cam_i2c_write(cam_iic, device_addr, 0x548b, 0xa2)
    cam_i2c_write(cam_iic, device_addr, 0x548c, 0xb8)
    cam_i2c_write(cam_iic, device_addr, 0x548d, 0xcc)
    cam_i2c_write(cam_iic, device_addr, 0x548e, 0xe0)
    cam_i2c_write(cam_iic, device_addr, 0x548f, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5490, 0x3)
    cam_i2c_write(cam_iic, device_addr, 0x5491, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x5492, 0x3)
    cam_i2c_write(cam_iic, device_addr, 0x5493, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5494, 0x2)
    cam_i2c_write(cam_iic, device_addr, 0x5495, 0xa0)
    cam_i2c_write(cam_iic, device_addr, 0x5496, 0x2)
    cam_i2c_write(cam_iic, device_addr, 0x5497, 0x48)
    cam_i2c_write(cam_iic, device_addr, 0x5498, 0x2)
    cam_i2c_write(cam_iic, device_addr, 0x5499, 0x26)
    cam_i2c_write(cam_iic, device_addr, 0x549a, 0x2)
    cam_i2c_write(cam_iic, device_addr, 0x549b, 0xb)
    cam_i2c_write(cam_iic, device_addr, 0x549c, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x549d, 0xee)
    cam_i2c_write(cam_iic, device_addr, 0x549e, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x549f, 0xd8)
    cam_i2c_write(cam_iic, device_addr, 0x54a0, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54a1, 0xc7)
    cam_i2c_write(cam_iic, device_addr, 0x54a2, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54a3, 0xb3)
    cam_i2c_write(cam_iic, device_addr, 0x54a4, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54a5, 0x90)
    cam_i2c_write(cam_iic, device_addr, 0x54a6, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54a7, 0x62)
    cam_i2c_write(cam_iic, device_addr, 0x54a8, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54a9, 0x27)
    cam_i2c_write(cam_iic, device_addr, 0x54aa, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54ab, 0x09)
    cam_i2c_write(cam_iic, device_addr, 0x54ac, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x54ad, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x54ae, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x54af, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x54b0, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54b1, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x54b2, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54b3, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x54b4, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x54b5, 0xf0)
    cam_i2c_write(cam_iic, device_addr, 0x54b6, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x54b7, 0xdf)
    cam_i2c_write(cam_iic, device_addr, 0x5583, 0x5d)
    cam_i2c_write(cam_iic, device_addr, 0x5584, 0x5d)
    cam_i2c_write(cam_iic, device_addr, 0x5580, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x5587, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5588, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x558a, 0x09)
    cam_i2c_write(cam_iic, device_addr, 0x5589, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5000, 0xcf)
    cam_i2c_write(cam_iic, device_addr, 0x5800, 0x48)
    cam_i2c_write(cam_iic, device_addr, 0x5801, 0x31)
    cam_i2c_write(cam_iic, device_addr, 0x5802, 0x21)
    cam_i2c_write(cam_iic, device_addr, 0x5803, 0x1b)
    cam_i2c_write(cam_iic, device_addr, 0x5804, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x5805, 0x1e)
    cam_i2c_write(cam_iic, device_addr, 0x5806, 0x29)
    cam_i2c_write(cam_iic, device_addr, 0x5807, 0x38)
    cam_i2c_write(cam_iic, device_addr, 0x5808, 0x26)
    cam_i2c_write(cam_iic, device_addr, 0x5809, 0x17)
    cam_i2c_write(cam_iic, device_addr, 0x580a, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x580b, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x580c, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x580d, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x580e, 0x13)
    cam_i2c_write(cam_iic, device_addr, 0x580f, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x5810, 0x15)
    cam_i2c_write(cam_iic, device_addr, 0x5811, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5812, 0x8)
    cam_i2c_write(cam_iic, device_addr, 0x5813, 0x5)
    cam_i2c_write(cam_iic, device_addr, 0x5814, 0x4)
    cam_i2c_write(cam_iic, device_addr, 0x5815, 0x5)
    cam_i2c_write(cam_iic, device_addr, 0x5816, 0x9)
    cam_i2c_write(cam_iic, device_addr, 0x5817, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5818, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x5819, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x581a, 0x4)
    cam_i2c_write(cam_iic, device_addr, 0x581b, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x581c, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x581d, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x581e, 0x6)
    cam_i2c_write(cam_iic, device_addr, 0x581f, 0x9)
    cam_i2c_write(cam_iic, device_addr, 0x5820, 0x12)
    cam_i2c_write(cam_iic, device_addr, 0x5821, 0xb)
    cam_i2c_write(cam_iic, device_addr, 0x5822, 0x4)
    cam_i2c_write(cam_iic, device_addr, 0x5823, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5824, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5825, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x5826, 0x6)
    cam_i2c_write(cam_iic, device_addr, 0x5827, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x5828, 0x17)
    cam_i2c_write(cam_iic, device_addr, 0x5829, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x582a, 0x9)
    cam_i2c_write(cam_iic, device_addr, 0x582b, 0x6)
    cam_i2c_write(cam_iic, device_addr, 0x582c, 0x5)
    cam_i2c_write(cam_iic, device_addr, 0x582d, 0x6)
    cam_i2c_write(cam_iic, device_addr, 0x582e, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x582f, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x5830, 0x28)
    cam_i2c_write(cam_iic, device_addr, 0x5831, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x5832, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x5833, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x5834, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x5835, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x5836, 0x15)
    cam_i2c_write(cam_iic, device_addr, 0x5837, 0x1d)
    cam_i2c_write(cam_iic, device_addr, 0x5838, 0x6e)
    cam_i2c_write(cam_iic, device_addr, 0x5839, 0x39)
    cam_i2c_write(cam_iic, device_addr, 0x583a, 0x27)
    cam_i2c_write(cam_iic, device_addr, 0x583b, 0x1f)
    cam_i2c_write(cam_iic, device_addr, 0x583c, 0x1e)
    cam_i2c_write(cam_iic, device_addr, 0x583d, 0x23)
    cam_i2c_write(cam_iic, device_addr, 0x583e, 0x2f)
    cam_i2c_write(cam_iic, device_addr, 0x583f, 0x41)
    cam_i2c_write(cam_iic, device_addr, 0x5840, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x5841, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5842, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5843, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5844, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5845, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5846, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5847, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5848, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5849, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x584a, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x584b, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x584c, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x584d, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x584e, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x584f, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5850, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x5851, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x5852, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x5853, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x5854, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5855, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5856, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5857, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x5858, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x5859, 0xe)
    cam_i2c_write(cam_iic, device_addr, 0x585a, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x585b, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x585c, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x585d, 0xa)
    cam_i2c_write(cam_iic, device_addr, 0x585e, 0x9)
    cam_i2c_write(cam_iic, device_addr, 0x585f, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5860, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x5861, 0xb)
    cam_i2c_write(cam_iic, device_addr, 0x5862, 0xd)
    cam_i2c_write(cam_iic, device_addr, 0x5863, 0x7)
    cam_i2c_write(cam_iic, device_addr, 0x5864, 0x17)
    cam_i2c_write(cam_iic, device_addr, 0x5865, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5866, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x5867, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x5868, 0x16)
    cam_i2c_write(cam_iic, device_addr, 0x5869, 0x12)
    cam_i2c_write(cam_iic, device_addr, 0x586a, 0x1b)
    cam_i2c_write(cam_iic, device_addr, 0x586b, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x586c, 0x16)
    cam_i2c_write(cam_iic, device_addr, 0x586d, 0x16)
    cam_i2c_write(cam_iic, device_addr, 0x586e, 0x18)
    cam_i2c_write(cam_iic, device_addr, 0x586f, 0x1f)
    cam_i2c_write(cam_iic, device_addr, 0x5870, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x5871, 0x16)
    cam_i2c_write(cam_iic, device_addr, 0x5872, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x5873, 0xf)
    cam_i2c_write(cam_iic, device_addr, 0x5874, 0x13)
    cam_i2c_write(cam_iic, device_addr, 0x5875, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x5876, 0x1e)
    cam_i2c_write(cam_iic, device_addr, 0x5877, 0x17)
    cam_i2c_write(cam_iic, device_addr, 0x5878, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x5879, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x587a, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x587b, 0x1e)
    cam_i2c_write(cam_iic, device_addr, 0x587c, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x587d, 0x1c)
    cam_i2c_write(cam_iic, device_addr, 0x587e, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x587f, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x5880, 0x1b)
    cam_i2c_write(cam_iic, device_addr, 0x5881, 0x1f)
    cam_i2c_write(cam_iic, device_addr, 0x5882, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5883, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x5884, 0x1d)
    cam_i2c_write(cam_iic, device_addr, 0x5885, 0x1e)
    cam_i2c_write(cam_iic, device_addr, 0x5886, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x5887, 0x1a)
    cam_i2c_write(cam_iic, device_addr, 0x528a, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x528b, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x528c, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x528d, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x528e, 0x40)
    cam_i2c_write(cam_iic, device_addr, 0x528f, 0x50)
    cam_i2c_write(cam_iic, device_addr, 0x5290, 0x60)
    cam_i2c_write(cam_iic, device_addr, 0x5292, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5293, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x5294, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5295, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x5296, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5297, 0x08)
    cam_i2c_write(cam_iic, device_addr, 0x5298, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5299, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x529a, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529b, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x529c, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529d, 0x28)
    cam_i2c_write(cam_iic, device_addr, 0x529e, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x529f, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x5282, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5680, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5681, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5682, 0x05)
    cam_i2c_write(cam_iic, device_addr, 0x5683, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5684, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5685, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x5686, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x5687, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x5180, 0xff)
    cam_i2c_write(cam_iic, device_addr, 0x5181, 0x52)
    cam_i2c_write(cam_iic, device_addr, 0x5182, 0x11)
    cam_i2c_write(cam_iic, device_addr, 0x5183, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5184, 0x25)
    cam_i2c_write(cam_iic, device_addr, 0x5185, 0x24)
    cam_i2c_write(cam_iic, device_addr, 0x5186, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5187, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5188, 0x14)
    cam_i2c_write(cam_iic, device_addr, 0x5189, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x518a, 0x60)
    cam_i2c_write(cam_iic, device_addr, 0x518b, 0xa2)
    cam_i2c_write(cam_iic, device_addr, 0x518c, 0x9c)
    cam_i2c_write(cam_iic, device_addr, 0x518d, 0x36)
    cam_i2c_write(cam_iic, device_addr, 0x518e, 0x34)
    cam_i2c_write(cam_iic, device_addr, 0x518f, 0x54)
    cam_i2c_write(cam_iic, device_addr, 0x5190, 0x4c)
    cam_i2c_write(cam_iic, device_addr, 0x5191, 0xf8)
    cam_i2c_write(cam_iic, device_addr, 0x5192, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x5193, 0x70)
    cam_i2c_write(cam_iic, device_addr, 0x5194, 0xf0)
    cam_i2c_write(cam_iic, device_addr, 0x5195, 0xf0)
    cam_i2c_write(cam_iic, device_addr, 0x5196, 0x03)
    cam_i2c_write(cam_iic, device_addr, 0x5197, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x5198, 0x05)
    cam_i2c_write(cam_iic, device_addr, 0x5199, 0x2f)
    cam_i2c_write(cam_iic, device_addr, 0x519a, 0x04)
    cam_i2c_write(cam_iic, device_addr, 0x519b, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x519c, 0x06)
    cam_i2c_write(cam_iic, device_addr, 0x519d, 0xa0)
    cam_i2c_write(cam_iic, device_addr, 0x519e, 0xa0)
    cam_i2c_write(cam_iic, device_addr, 0x3a0f, 0x3c)
    cam_i2c_write(cam_iic, device_addr, 0x3a10, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x3a1b, 0x3c)
    cam_i2c_write(cam_iic, device_addr, 0x3a1e, 0x30)
    cam_i2c_write(cam_iic, device_addr, 0x3a11, 0x70)
    cam_i2c_write(cam_iic, device_addr, 0x3a1f, 0x10)
    cam_i2c_write(cam_iic, device_addr, 0x3800, 0x1)
    cam_i2c_write(cam_iic, device_addr, 0x3801, 0x50)
    cam_i2c_write(cam_iic, device_addr, 0x3802, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x3803, 0x8)
    cam_i2c_write(cam_iic, device_addr, 0x3804, 0x5)
    cam_i2c_write(cam_iic, device_addr, 0x3805, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x3806, 0x3)
    cam_i2c_write(cam_iic, device_addr, 0x3807, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x3808, 0x3)
    cam_i2c_write(cam_iic, device_addr, 0x3809, 0x20)
    cam_i2c_write(cam_iic, device_addr, 0x380a, 0x2)
    cam_i2c_write(cam_iic, device_addr, 0x380b, 0x58)
    cam_i2c_write(cam_iic, device_addr, 0x380c, 0xc)
    cam_i2c_write(cam_iic, device_addr, 0x380d, 0x80)
    cam_i2c_write(cam_iic, device_addr, 0x380e, 0x3)
    cam_i2c_write(cam_iic, device_addr, 0x380f, 0xe8)
    cam_i2c_write(cam_iic, device_addr, 0x5001, 0x7f)
    cam_i2c_write(cam_iic, device_addr, 0x5680, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5681, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5682, 0x5)
    cam_i2c_write(cam_iic, device_addr, 0x5683, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5684, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5685, 0x0)
    cam_i2c_write(cam_iic, device_addr, 0x5686, 0x3)
    cam_i2c_write(cam_iic, device_addr, 0x5687, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x5687, 0xc0)
    cam_i2c_write(cam_iic, device_addr, 0x3815, 0x02)
    cam_i2c_write(cam_iic, device_addr, 0x3503, 0x00)
    cam_i2c_write(cam_iic, device_addr, 0x3818, 0x81) # No Mirror
    cam_i2c_write(cam_iic, device_addr, 0x3621, 0xa7)

    cam_i2c_write(cam_iic, device_addr, 0x4740, 0x21)

    cam_i2c_write(cam_iic, device_addr, 0x501e, 0x2a)
    cam_i2c_write(cam_iic, device_addr, 0x5002, 0x78)
    cam_i2c_write(cam_iic, device_addr, 0x501f, 0x01)
    cam_i2c_write(cam_iic, device_addr, 0x4300, 0x61)

# frame buffer alocate
height = 600
width = 800
buffer0 = allocate(shape=(height, width, 1), dtype=np.uint32, cacheable=1)
buffer1 = allocate(shape=(height, width, 1), dtype=np.uint32, cacheable=1)
buffer2 = allocate(shape=(height, width, 1), dtype=np.uint32, cacheable=1)
buffer3 = allocate(shape=(height, width, 3), dtype=np.uint8, cacheable=1)

# frame buffer resister set
vflip_dmaw.register_map.fb0_1 = buffer0.physical_address
vflip_dmaw.register_map.fb0_2 = 0
vflip_dmaw.register_map.fb1_1 = buffer1.physical_address
vflip_dmaw.register_map.fb1_2 = 0
vflip_dmaw.register_map.fb2_1 = buffer2.physical_address
vflip_dmaw.register_map.fb2_2 = 0

dma2axis3.register_map.fb0 = buffer0.physical_address
dma2axis3.register_map.fb1 = buffer1.physical_address
dma2axis3.register_map.fb2 = buffer2.physical_address
dma2axis3.register_map.mode = 0 # DMA_WRITE_MODE

sobel.register_map.row_size = height
sobel.register_map.col_size = width
sobel.register_map.function_r = 0 # ORG_IMGwAxiVdma

axis2dma.register_map.out_r = buffer3.physical_address
axis2dma.register_map.row_size = height
axis2dma.register_map.col_size = width

# vflip_dma_write start and auto repeat
vflip_dmaw.register_map.CTRL = 0x81

# Camera Initialization
cam_i2c_init(cam_iic)
cam_reg_set(cam_iic, 0x78)

# paracam_inf_axi start
paracam_inf.write(0x0, 0x0)
paracam_inf.write(0x4, 0x0)

# bitmap_disp_cont start
bmpd_cont.write(0x0, 0x0)

# sobel_axis_RGB24 start
sobel.register_map.CTRL = 0x81

# dma2axis_3buf start and auto repeat
dma2axis3.register_map.CTRL = 0x81

axis2dma.register_map.CTRL = 0x1

print(axis2dma.register_map.CTRL)

cam_image = Image.fromarray(buffer3)
print("Image size: {}x{} pixels.".format(width, height))
plt.figure(figsize=(12, 10));
_ = plt.imshow(cam_image)

#sobel filter on
sobel.register_map.function_r = 1 # SOBELwAxiVdma

# sobel filter off
sobel.register_map.function_r = 0 # ORG_IMGwAxiVdma

  1. 2022年08月21日 04:31 |
  2. PYNQ
  3. | トラックバック:0
  4. | コメント:0

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック URL
https://marsee101.blog.fc2.com/tb.php/5682-c8026934
この記事にトラックバックする(FC2ブログユーザー)