Skip to content

Commit eff0730

Browse files
authored
Add vStream VideoIn/VideoOut implementation using VSI (#33)
1 parent c3164a7 commit eff0730

File tree

13 files changed

+3217
-13
lines changed

13 files changed

+3217
-13
lines changed

ARM.AVH_FVP.pdsc

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,16 @@
33
<name>AVH_FVP</name>
44
<vendor>ARM</vendor>
55
<description>Virtual Interfaces for Arm FVPs</description>
6-
<url>https://github.com/ARM-software/AVH</url>
6+
<url>https://github.com/ARM-software/AVH/</url>
77
<repository type="git">https://github.com/ARM-software/AVH.git</repository>
88
<license>LICENSE</license>
99

1010
<releases>
11-
<release version="1.1.0-dev1">
12-
Add vStream AudioIn/Out drivers
13-
Update VIO to API 1.0.0
14-
</release>
15-
<release version="1.1.0-dev0">
16-
Pack Description:
17-
- Add LICENSE file
18-
- Update schemaVersion (1.7.28)
19-
- Update URL and repository type
20-
</release>
21-
<release version="1.0.0">
22-
Initial release
11+
<release version="1.0.0-dev">
12+
Active development ...
13+
- Add VIO driver
14+
- Add vStream AudioIn/Out drivers
15+
- Add vSocket driver
2316
</release>
2417
</releases>
2518

@@ -72,6 +65,34 @@
7265
</files>
7366
</component>
7467

68+
<component Cclass="CMSIS Driver" Cgroup="vStream" Csub="VideoIn" Cversion="1.0.0" Capiversion="1.0.0" condition="vStream">
69+
<description>Video Input vStream implementation for Arm FVPs</description>
70+
<RTE_Components_h>
71+
#define RTE_VSTREAM_AUDIOIN
72+
</RTE_Components_h>
73+
<files>
74+
<file category="doc" name="Documentation/simulation/html/group__arm__vsi.html"/>
75+
<file category="include" name="interface/include/"/>
76+
<file category="sourceC" name="interface/vstream/source/vstream_video_in.c"/>
77+
<file category="header" name="interface/vstream/source/vstream_video_in.h"/>
78+
<file category="header" name="interface/vstream/config/vstream_video_in_config.h" attr="config" version="1.0.0"/>
79+
</files>
80+
</component>
81+
82+
<component Cclass="CMSIS Driver" Cgroup="vStream" Csub="VideoOut" Cversion="1.0.0" Capiversion="1.0.0" condition="vStream">
83+
<description>Video Output vStream implementation for Arm FVPs</description>
84+
<RTE_Components_h>
85+
#define RTE_VSTREAM_AUDIOOUT
86+
</RTE_Components_h>
87+
<files>
88+
<file category="doc" name="Documentation/simulation/html/group__arm__vsi.html"/>
89+
<file category="include" name="interface/include/"/>
90+
<file category="sourceC" name="interface/vstream/source/vstream_video_out.c"/>
91+
<file category="header" name="interface/vstream/source/vstream_video_out.h"/>
92+
<file category="header" name="interface/vstream/config/vstream_video_out_config.h" attr="config" version="1.0.0"/>
93+
</files>
94+
</component>
95+
7596
<component Cclass="IoT Utility" Cgroup="Socket" Csub="VSocket" Capiversion="1.2.0" Cversion="1.0.0" condition="VSocket">
7697
<description>IoT Socket implementation for Arm FVPs</description>
7798
<RTE_Components_h>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*---------------------------------------------------------------------------
2+
* Copyright (c) 2025 Arm Limited (or its affiliates).
3+
* All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*---------------------------------------------------------------------------*/
18+
19+
#ifndef VSTREAM_VIDEO_IN_CONFIG_H_
20+
#define VSTREAM_VIDEO_IN_CONFIG_H_
21+
22+
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
23+
//------ With VS Code: Open Preview for Configuration Wizard -------------------
24+
25+
// <o> Frame width
26+
// <i> Defines the video stream frame width in pixels.
27+
#ifndef VIDEO_IN_FRAME_WIDTH
28+
#define VIDEO_IN_FRAME_WIDTH 320
29+
#endif
30+
31+
// <o> Frame height
32+
// <i> Defines the video stream frame height in pixels.
33+
#ifndef VIDEO_IN_FRAME_HEIGHT
34+
#define VIDEO_IN_FRAME_HEIGHT 240
35+
#endif
36+
37+
// <o> Frame rate
38+
// <i> Defines the video stream frame rate in frames per second.
39+
#ifndef VIDEO_IN_FRAME_RATE
40+
#define VIDEO_IN_FRAME_RATE 30
41+
#endif
42+
43+
// <o> Color format <0=>Grayscale(8-bit) <1=>RGB888 <2=>BGR565 <3=>YUV420 <4=>NV12 <5=>NV21
44+
// <i> Defines the video frame color space.
45+
#ifndef VIDEO_IN_FRAME_COLOR
46+
#define VIDEO_IN_FRAME_COLOR 1
47+
#endif
48+
49+
#endif
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*---------------------------------------------------------------------------
2+
* Copyright (c) 2025 Arm Limited (or its affiliates).
3+
* All rights reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*---------------------------------------------------------------------------*/
18+
19+
#ifndef VSTREAM_VIDEO_OUT_CONFIG_H_
20+
#define VSTREAM_VIDEO_OUT_CONFIG_H_
21+
22+
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
23+
//------ With VS Code: Open Preview for Configuration Wizard -------------------
24+
25+
// <o> Frame width
26+
// <i> Defines the video stream frame width in pixels.
27+
#ifndef VIDEO_OUT_FRAME_WIDTH
28+
#define VIDEO_OUT_FRAME_WIDTH 320
29+
#endif
30+
31+
// <o> Frame height
32+
// <i> Defines the video stream frame height in pixels.
33+
#ifndef VIDEO_OUT_FRAME_HEIGHT
34+
#define VIDEO_OUT_FRAME_HEIGHT 240
35+
#endif
36+
37+
// <o> Frame rate
38+
// <i> Defines the video stream frame rate in frames per second.
39+
#ifndef VIDEO_OUT_FRAME_RATE
40+
#define VIDEO_OUT_FRAME_RATE 30
41+
#endif
42+
43+
// <o> Color format <0=>Grayscale(8-bit) <1=>RGB888 <2=>BGR565 <3=>YUV420 <4=>NV12 <5=>NV21
44+
// <i> Defines the video frame color space.
45+
#ifndef VIDEO_OUT_FRAME_COLOR
46+
#define VIDEO_OUT_FRAME_COLOR 1
47+
#endif
48+
49+
#endif
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# Copyright (c) 2021-2025 Arm Limited. All rights reserved.
2+
3+
# Virtual Streaming Interface instance 4 Python script
4+
5+
##@addtogroup arm_vsi_py_video
6+
# @{
7+
#
8+
##@package arm_vsi4_video
9+
#Documentation for VSI peripherals module.
10+
#
11+
#More details.
12+
13+
import logging
14+
import vsi_video
15+
16+
logger = logging.getLogger(__name__)
17+
vsi_video.logger = logger
18+
19+
## Set verbosity level
20+
#verbosity = logging.DEBUG
21+
#verbosity = logging.INFO
22+
#verbosity = logging.WARNING
23+
verbosity = logging.ERROR
24+
25+
# [debugging] Verbosity settings
26+
level = { 10: "DEBUG", 20: "INFO", 30: "WARNING", 40: "ERROR" }
27+
logging.basicConfig(format='Py: %(name)s : [%(levelname)s]\t%(message)s', level = verbosity)
28+
logger.info("Verbosity level is set to " + level[verbosity])
29+
30+
31+
# Video Server configuration
32+
server_address = ('127.0.0.1', 6000)
33+
server_authkey = 'vsi_video'
34+
35+
36+
# IRQ registers
37+
IRQ_Status = 0
38+
39+
# Timer registers
40+
Timer_Control = 0
41+
Timer_Interval = 0
42+
43+
# Timer Control register definitions
44+
Timer_Control_Run_Msk = 1<<0
45+
Timer_Control_Periodic_Msk = 1<<1
46+
Timer_Control_Trig_IRQ_Msk = 1<<2
47+
Timer_Control_Trig_DMA_Msk = 1<<3
48+
49+
# DMA registers
50+
DMA_Control = 0
51+
52+
# DMA Control register definitions
53+
DMA_Control_Enable_Msk = 1<<0
54+
DMA_Control_Direction_Msk = 1<<1
55+
DMA_Control_Direction_P2M = 0<<1
56+
DMA_Control_Direction_M2P = 1<<1
57+
58+
# User registers
59+
Regs = [0] * 64
60+
61+
# Data buffer
62+
Data = bytearray()
63+
64+
# Streaming Server Connection Status
65+
Server_Connected = False
66+
67+
68+
69+
## Initialize
70+
# @return None
71+
def init():
72+
global Server_Connected
73+
logger.info("init() called")
74+
75+
Server_Connected = vsi_video.init(server_address, server_authkey)
76+
77+
78+
## Read interrupt request (the VSI IRQ Status Register)
79+
# @return value value read (32-bit)
80+
def rdIRQ():
81+
global IRQ_Status
82+
logger.info("rdIRQ() called")
83+
84+
value = IRQ_Status
85+
logger.debug(f"Read IRQ_Status: 0x{value:08X}")
86+
87+
return value
88+
89+
90+
## Write interrupt request (the VSI IRQ Status Register)
91+
# @param value value to write (32-bit)
92+
# @return value value written (32-bit)
93+
def wrIRQ(value):
94+
global IRQ_Status
95+
logger.info(f"wrIRQ(value=0x{value:08X}) called")
96+
97+
IRQ_Status = value
98+
logger.debug(f"wrIRQ: write IRQ_Status: 0x{value:08X}")
99+
100+
return value
101+
102+
103+
## Write Timer registers (the VSI Timer Registers)
104+
# @param index Timer register index (zero based)
105+
# @param value value to write (32-bit)
106+
# @return value value written (32-bit)
107+
def wrTimer(index, value):
108+
global Timer_Control, Timer_Interval
109+
logger.info(f"wrTimer(index={index}, value=0x{value:08X}) called")
110+
111+
if index == 0:
112+
Timer_Control = value
113+
logger.debug(f"wrTimer: write Timer_Control: 0x{value:08X}")
114+
elif index == 1:
115+
Timer_Interval = value
116+
logger.debug(f"wrTimer: write Timer_Interval: 0x{value:08X}")
117+
118+
return value
119+
120+
121+
## Timer event (called at Timer Overflow)
122+
# @return None
123+
def timerEvent():
124+
logger.info("timerEvent() called")
125+
126+
if Server_Connected:
127+
vsi_video.timerEvent()
128+
129+
130+
## Write DMA registers (the VSI DMA Registers)
131+
# @param index DMA register index (zero based)
132+
# @param value value to write (32-bit)
133+
# @return value value written (32-bit)
134+
def wrDMA(index, value):
135+
global DMA_Control
136+
logger.info(f"wrDMA(index={index}, value=0x{value:08X}) called")
137+
138+
if index == 0:
139+
DMA_Control = value
140+
logger.debug(f"wrDMA: write DMA_Control: 0x{value:08X}")
141+
142+
return value
143+
144+
145+
## Read data from peripheral for DMA P2M transfer (VSI DMA)
146+
# @param size size of data to read (in bytes, multiple of 4)
147+
# @return data data read (bytearray)
148+
def rdDataDMA(size):
149+
global Data
150+
logger.info(f"rdDataDMA(size={size}) called")
151+
152+
if Server_Connected:
153+
Data = vsi_video.rdDataDMA(size)
154+
155+
n = min(len(Data), size)
156+
data = bytearray(size)
157+
data[0:n] = Data[0:n]
158+
logger.debug(f"rdDataDMA: read data ({size} bytes)")
159+
160+
return data
161+
162+
163+
## Write data to peripheral for DMA M2P transfer (VSI DMA)
164+
# @param data data to write (bytearray)
165+
# @param size size of data to write (in bytes, multiple of 4)
166+
# @return None
167+
def wrDataDMA(data, size):
168+
global Data
169+
logger.info(f"wrDataDMA(data={type(data).__name__}, size={size}) called")
170+
171+
Data = data
172+
logger.debug(f"wrDataDMA: write data ({size} bytes)")
173+
174+
if Server_Connected:
175+
vsi_video.wrDataDMA(data, size)
176+
177+
return
178+
179+
180+
## Read user registers (the VSI User Registers)
181+
# @param index user register index (zero based)
182+
# @return value value read (32-bit)
183+
def rdRegs(index):
184+
global Regs
185+
logger.info(f"rdRegs(index={index}) called")
186+
187+
if Server_Connected:
188+
Regs[index] = vsi_video.rdRegs(index)
189+
190+
value = Regs[index]
191+
192+
# Log the value read from the register
193+
logger.debug(f"rdRegs: read Regs[{index}]: 0x{value:08X}")
194+
195+
return value
196+
197+
198+
## Write user registers (the VSI User Registers)
199+
# @param index user register index (zero based)
200+
# @param value value to write (32-bit)
201+
# @return value value written (32-bit)
202+
def wrRegs(index, value):
203+
global Regs
204+
logger.info(f"wrRegs(index={index}, value=0x{value:08X}) called")
205+
206+
if Server_Connected:
207+
value = vsi_video.wrRegs(index, value)
208+
209+
Regs[index] = value
210+
211+
# Log the value written to the register
212+
logger.debug(f"wrRegs: write Regs[{index}] = 0x{value:08X}")
213+
214+
return value
215+
216+
217+
## @}

0 commit comments

Comments
 (0)