Commit 47a0e5d7 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Add a video HAL device to allow BCMVideo to determine which DMA channel it can use for render ops

Detail:
  hdr/StaticWS, s/Top, s/Video - Added a simple VDU HAL device that exposes a DMA channel to BCMVideo for use with GraphicsV_Render
  hdr/BCM2835 - Don't allow DMA channel 12 to be used; latest firmware seems to have a bug which claims its free when in reality it isn't.
  s/Messaging, s/DMA - Adjust DMA init to allow the video device to claim a DMA channel before the DMA devices are initialised
Admin:
  Tested on Raspberry Pi with high processor vectors


Version 0.25. Tagged as 'BCM2835-0_25'
parent a1c4df2f
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.24"
Module_Version SETA 24
Module_MajorVersion SETS "0.25"
Module_Version SETA 25
Module_MinorVersion SETS ""
Module_Date SETS "10 Sep 2012"
Module_ApplicationDate SETS "10-Sep-12"
Module_Date SETS "18 Sep 2012"
Module_ApplicationDate SETS "18-Sep-12"
Module_ComponentName SETS "BCM2835"
Module_ComponentPath SETS "mixed/RiscOS/Sources/HAL/BCM2835"
Module_FullVersion SETS "0.24"
Module_HelpVersion SETS "0.24 (10 Sep 2012)"
Module_FullVersion SETS "0.25"
Module_HelpVersion SETS "0.25 (18 Sep 2012)"
END
/* (0.24)
/* (0.25)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.24
#define Module_MajorVersion_CMHG 0.25
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 10 Sep 2012
#define Module_Date_CMHG 18 Sep 2012
#define Module_MajorVersion "0.24"
#define Module_Version 24
#define Module_MajorVersion "0.25"
#define Module_Version 25
#define Module_MinorVersion ""
#define Module_Date "10 Sep 2012"
#define Module_Date "18 Sep 2012"
#define Module_ApplicationDate "10-Sep-12"
#define Module_ApplicationDate "18-Sep-12"
#define Module_ComponentName "BCM2835"
#define Module_ComponentPath "mixed/RiscOS/Sources/HAL/BCM2835"
#define Module_FullVersion "0.24"
#define Module_HelpVersion "0.24 (10 Sep 2012)"
#define Module_LibraryVersionInfo "0:24"
#define Module_FullVersion "0.25"
#define Module_HelpVersion "0.25 (18 Sep 2012)"
#define Module_LibraryVersionInfo "0:25"
......@@ -409,7 +409,8 @@ ARM_Timer_Base * &0000b400 ; base of ARM timer regs
; DMA registers
DMA_Base * &00007000
DMA_CH_Count * 13 ; Allegedly 16 channels, but can only get IRQs from 13 of them?
; DMA_CH_Count * 13 ; Allegedly 16 channels, but can only get IRQs from 13 of them?
DMA_CH_Count * 12 ; Was 13, but firmware bug is incorrectly reporting that ch 12 is available
;
PM_Base * &00100000 ; power management
......
......@@ -35,6 +35,7 @@
GET Hdr:SDHCIDevice
GET Hdr:DMADevice
GET Hdr:GPIODevice
GET Hdr:VideoDevice
GET hdr.BCM2835
; Per-timer workspace layout
......@@ -70,6 +71,14 @@ HALDevice_VCHIQARMDoorbell # 4 ; Doorbell to interrupt us
HALDevice_VCHIQInitVC # 4
HALDevice_VCHIQ_Size * :INDEX: @
; Device-specific struct for the VDU device
^ 0
VDUDevSpec_SizeField # 4 ; Size field
VDUDevSpec_DMAChan # 4 ; Pointer to DMA channel
VDUDevSpec_BurstLen # 4 ; Burst length for use with DMA channel
VDUDevSpec_Size # 0 ; Size value to write to size field
; Main workspace layout
sb RN 9
......@@ -146,8 +155,9 @@ DMAController # HALDevice_DMAC_Size_0_1 ; see Hdr:HALDevice
DMAChannels # DMAC_DeviceSize*DMA_CH_Count ; List of channel devices (indexed by physical channel #)
VCHIQDevice # HALDevice_VCHIQ_Size
GPIODevice # HALDevice_GPIO_Size
VDUDevice # HALDevice_VDU_Size
VDUDevSpec # VDUDevSpec_Size
HAL_WsSize * :INDEX:@
sizeof_workspace * :INDEX:@
......
......@@ -165,10 +165,9 @@ DMA_InitDevices ROUT
BL HAL_DebugHexTX4
DebugTX "GetDMAChannels response"
]
CMP v5, #0
MOVEQ v5, #1<<4 ; Default mask of which channels we're allowed to use (from Linux)
LDR a1, =(1<<DMA_CH_Count)-1
AND v5, v5, a1 ; Mask with the list of channels that we know how to use
ANDS v5, v5, a1 ; Mask with the list of channels that we know how to use
EXIT EQ ; Exit if none available (may have been claimed by video)
STR v5, DMAFreeChannels
; Create DMA controller device
ADR a1, DMAController
......
......@@ -135,6 +135,10 @@ lp1 ldr r3, [r0], #4 ; copy to workspace buffer
LDR r2, [r5, #dmachans-tagb]
STR r0, Board_Model
STR r1, Board_Revision
; If no channels are reported as available, use channel 4
; (Matches default channel mask from Linux)
CMP r2, #0
MOVEQ r2, #1<<4
STR r2, ARM_DMAChannels
; copy out and construct machine ID from MAC address
......
......@@ -151,6 +151,8 @@
IMPORT VCHIQ_InitDevices
IMPORT Video_InitDevices
IMPORT HAL_SendHostMessage
IMPORT HAL_QueryPlatform
......@@ -789,6 +791,7 @@ HAL_Null
HAL_InitDevices
STR lr, [sp, #-4]!
BL Video_InitDevices ; Must be before DMA_InitDevices
BL SDIO_InitDevices
BL DMA_InitDevices
BL GPIO_InitDevices
......
......@@ -33,8 +33,11 @@
AREA |ARM$$code|, CODE, READONLY, PIC
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:Proc
GET hdr.BCM2835
GET hdr.StaticWS
GET hdr.DMA
[ HALDebug
IMPORT HAL_DebugTX
......@@ -60,6 +63,27 @@
EXPORT HAL_Video_IICOp
EXPORT HAL_Video_FramestoreAddress
EXPORT HAL_Video_StartupMode
EXPORT Video_InitDevices
IMPORT memcpy
MACRO
$class HALDeviceField $field, $value
LCLS myvalue
[ "$value" = ""
myvalue SETS "$field"
|
myvalue SETS "$value"
]
ASSERT . - %A0 = HALDevice_$class$field
[ ?HALDevice_$class$field = 2
DCW $myvalue
ELIF ?HALDevice_$class$field = 4
DCD $myvalue
|
% ?HALDevice_$class$field
]
MEND
HAL_Video_FramestoreAddress
MOV r1, #0
......@@ -109,4 +133,82 @@ DefaultModeList
DCD -1
DCD -1
; Template for video device
VDU_Dev
0
HALDeviceField Type, HALDeviceType_Video + HALDeviceVideo_VDU
HALDeviceField ID, HALDeviceID_VDU_BCM2835
HALDeviceField Location, HALDeviceBus_Sys + HALDeviceSysBus_AHB ; Guess
HALDeviceField Version, 0
HALDeviceField Description, VDU_Description
HALDeviceField Address, 0
HALDeviceField Reserved1, 0
HALDeviceField Activate, VDU_Activate
HALDeviceField Deactivate, VDU_Deactivate
HALDeviceField Reset, VDU_Reset
HALDeviceField Sleep, VDU_Sleep
HALDeviceField Device, -1
HALDeviceField TestIRQ, 0
HALDeviceField ClearIRQ, 0
HALDeviceField Reserved2, 0
VDU HALDeviceField DeviceSpecificField,0 ; Filled in at runtime
ASSERT . - %A0 = HALDevice_VDU_Size
VDU_Description
= "BCM2835 VDU device", 0
ALIGN
Video_InitDevices
Entry
ADRL a1, VDUDevice
ADR a2, VDU_Dev
MOV a3, #HALDevice_VDU_Size
BL memcpy
; Select a DMA channel to use for GraphicsV_Render
; We prefer channel 0, but will use any non-lite channel if channel 0 unavailable
LDR a3, PeriBase
ADD a3, a3, #DMA_Base
LDR a1, ARM_DMAChannels
MOV a4, #8 ; Burst length of 8 possible for DMA channel 0. 9 also possible but seemed to be slower!
MOV a2, #1
AND a1, a1, #(:NOT: DMA_CH_is_lite) :AND: ((1<<DMA_CH_Count)-1) ; Mask with available non-lite channels
10
TST a1, a2
BNE %FT20
MOV a4, #4 ; Use 4 for other channels (7 will cause a lockup, haven't tried anything else inbetween)
ADD a3, a3, #DMA_CH_STRIDE
MOVS a2, a2, LSL #1
BCC %BT10
MOV a3, #0
MOV a4, #0
20
; Claim the channel (if any)
LDR a1, ARM_DMAChannels
BIC a1, a1, a2
STR a1, ARM_DMAChannels
; Fill in the device specific field
ADRL a1, VDUDevSpec
STR a3, [a1, #VDUDevSpec_DMAChan]
STR a4, [a1, #VDUDevSpec_BurstLen]
MOV a3, #VDUDevSpec_Size
STR a3, [a1, #VDUDevSpec_SizeField]
; Register the device
ADRL a2, VDUDevice
STR a1, [a2, #HALDevice_VDUDeviceSpecificField]
MOV a1, #0
MOV lr, pc
LDR pc, OSentries+4*OS_AddDevice
EXIT
VDU_Activate
MOV a1, #1
VDU_Deactivate
VDU_Reset
MOV pc, lr
VDU_Sleep
MOV a1, #0
MOV pc, lr
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment