Commit 5a615665 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

First working version of video driver

Detail:
  This version of the driver supports 8bpp & 32bpp screen modes, and uses a software mouse pointer.
  Startup mode is forced to 1080p, 32bpp (via code in the HAL). After that, RISC OS is free to do as it pleases.
  Makefile, s/BCMVideo - Added Castle licence text
  Resources/RPIMon - Simple MDF that gets loaded on startup. Contains simple 1080p & 720p mode definitions, plus copies of definitions for numbered modes from AKF50 MDF (to ensure RISC OS doesn't freak out due to not having any fallback modes available)
  s/BCMVideo - Main bulk of video driver
  s/Debug - Debug routines
  s/GraphicsV - GraphicsV handler
  s/SWPointer - Basic software mouse pointer implementation
Admin:
  Tested on Raspberry Pi with high processor vectors
  Still a few rough edges to iron out, but code seems stable enough


Version 0.03. Tagged as 'BCMVideo-0_03'
parent 0ecfca33
# Copyright 2012 Castle Technology Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Makefile for BCMVideo
COMPONENT = BCMVideo
TARGET = BCMVideo
# By default, the shared makefiles do a lot of the work of installing a
# Mesages file in ResourceFS. This is how to overrides it:
RES_OBJ =
RES_OBJ =
# By default, the shared makefiles assume you want to use CMHG to create
# your module header. This is how to override it:
......@@ -14,6 +29,7 @@ CMHGFILE =
#ASMHDRS =
#ASMCHDRS =
HDRS =
OBJS = BCMVideo
# CModule is equally useful for assembler modules. Its advantages over the
# AAmModule makefile are that you can use multiple source files (permitting
......@@ -22,6 +38,5 @@ HDRS =
# in module initialisation.
include CModule
OBJS = BCMVideo
# Dynamic dependencies:
file_format:1
monitor_title:RasPi-Builtin
DPMS_state:3
# Mode: 1080P basic 1920 x 1080 @ ??Hz
startmode
mode_name:1920 x 1080
x_res:1920
y_res:1080
pixel_rate:150000
h_timings:0,0,0,1920,0,0
v_timings:0,0,0,1080,0,0
sync_pol:0
EndMode
# Mode: 720P basic 1280 x 720 @ ??Hz
startmode
mode_name:1280 x 720
x_res:1280
y_res:720
pixel_rate:70000
h_timings:0,0,0,1280,0,0
v_timings:0,0,0, 720,0,0
sync_pol:0
EndMode
# Standard numbered modes copied from AKF50 MDF
# Without these, RISC OS will try falling back to mode 0, and fail badly
# 640 x 200 (60Hz - Modes 44,45,46)
startmode
mode_name:
x_res:640
y_res:200
pixel_rate:16000
h_timings:72,146,16,640,16,130
v_timings:3,34,0,200,0,25
sync_pol:0
endmode
# 320 x 250 (50Hz - Modes 6,7)
startmode
mode_name:
x_res:320
y_res:250
pixel_rate:8000
h_timings:36,30,44,320,44,38
v_timings:3,16,20,250,20,3
sync_pol:0
endmode
# 640 x 250 (50Hz - Modes 3,11,14)
startmode
mode_name:
x_res:640
y_res:250
pixel_rate:16000
h_timings:72,62,88,640,88,74
v_timings:3,16,20,250,20,3
sync_pol:0
endmode
# 320 x 256 (50Hz - Modes 1,2,5,9,10,13)
startmode
mode_name:
x_res:320
y_res:256
pixel_rate:8000
h_timings:36,30,44,320,44,38
v_timings:3,16,17,256,17,3
sync_pol:0
endmode
# 640 x 256 (50Hz - Modes 0,4,8,12,15)
startmode
mode_name:
x_res:640
y_res:256
pixel_rate:16000
h_timings:72,62,88,640,88,74
v_timings:3,16,17,256,17,3
sync_pol:0
endmode
# 640 x 352 (60Hz - Modes 41,42,43)
startmode
mode_name:
x_res:640
y_res:352
pixel_rate:16783
h_timings:76,20,16,640,16,0
v_timings:3,9,0,352,0,0
sync_pol:2
endmode
# 1056 x 250 (50Hz - Modes 17)
startmode
mode_name:
x_res:1056
y_res:250
pixel_rate:24000
h_timings:108,72,106,1056,106,88
v_timings:3,16,20,250,20,3
sync_pol:0
endmode
# 1056 x 256 (50Hz - Modes 16,24)
startmode
mode_name:
x_res:1056
y_res:256
pixel_rate:24000
h_timings:108,72,106,1056,106,88
v_timings:3,16,17,256,17,3
sync_pol:0
endmode
# 768 x 288 (50Hz - Modes 22,33,34,35,36)
startmode
mode_name:
x_res:768
y_res:288
pixel_rate:16000
h_timings:76,66,16,768,16,82
v_timings:3,19,0,288,0,2
sync_pol:0
endmode
# 896 x 352 (60Hz - Modes 37,38,39,40)
startmode
mode_name:
x_res:896
y_res:352
pixel_rate:24000
h_timings:118,38,20,896,20,8
v_timings:3,9,0,352,0,0
sync_pol:2
endmode
# 320 x 480 (60Hz - Games modes 48,49)
startmode
mode_name:
x_res:320
y_res:480
pixel_rate:12587
h_timings:42,14,12,320,12,0
v_timings:2,32,0,480,0,11
sync_pol:3
endmode
# 360 x 480 (60Hz - PCSoft mode 47)
startmode
mode_name:
x_res:360
y_res:480
pixel_rate:16783
h_timings:64,46,16,360,16,30
v_timings:2,32,0,480,0,11
sync_pol:3
endmode
# 640 x 480 (60Hz - Modes 25,26,27,28)
startmode
mode_name:640 x 480
x_res:640
y_res:480
pixel_rate:25175
h_timings:94,22,22,640,22,0
v_timings:2,32,0,480,0,11
sync_pol:3
endmode
# 640 x 512 (50Hz - Modes 18,19,20,21)
startmode
mode_name:
x_res:640
y_res:512
pixel_rate:24000
h_timings:56,92,20,640,20,68
v_timings:3,18,0,512,0,1
sync_pol:0
endmode
# 800 x 600 (56Hz - Modes 29,30,31)
startmode
mode_name:800 x 600
x_res:800
y_res:600
pixel_rate:36000
h_timings:72,84,34,800,34,0
# VESA:72,128,0,800,0,24
v_timings:2,22,0,600,0,1
sync_pol:0
endmode
#End
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.02"
Module_Version SETA 2
Module_MajorVersion SETS "0.03"
Module_Version SETA 3
Module_MinorVersion SETS ""
Module_Date SETS "23 Jul 2012"
Module_ApplicationDate SETS "23-Jul-12"
Module_Date SETS "02 Sep 2012"
Module_ApplicationDate SETS "02-Sep-12"
Module_ComponentName SETS "BCMVideo"
Module_ComponentPath SETS "mixed/RiscOS/Sources/Video/HWSupport/BCMVideo"
Module_FullVersion SETS "0.02"
Module_HelpVersion SETS "0.02 (23 Jul 2012)"
Module_FullVersion SETS "0.03"
Module_HelpVersion SETS "0.03 (02 Sep 2012)"
END
/* (0.02)
/* (0.03)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.02
#define Module_MajorVersion_CMHG 0.03
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 23 Jul 2012
#define Module_Date_CMHG 02 Sep 2012
#define Module_MajorVersion "0.02"
#define Module_Version 2
#define Module_MajorVersion "0.03"
#define Module_Version 3
#define Module_MinorVersion ""
#define Module_Date "23 Jul 2012"
#define Module_Date "02 Sep 2012"
#define Module_ApplicationDate "23-Jul-12"
#define Module_ApplicationDate "02-Sep-12"
#define Module_ComponentName "BCMVideo"
#define Module_ComponentPath "mixed/RiscOS/Sources/Video/HWSupport/BCMVideo"
#define Module_FullVersion "0.02"
#define Module_HelpVersion "0.02 (23 Jul 2012)"
#define Module_LibraryVersionInfo "0:2"
#define Module_FullVersion "0.03"
#define Module_HelpVersion "0.03 (02 Sep 2012)"
#define Module_LibraryVersionInfo "0:3"
This diff is collapsed.
; Copyright 2012 Castle Technology Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;
[ Debug
; a2-> null terminated string
DebugTXS ROUT
STMFD sp!, {a1,lr}
SUB a2,a2,#1
1 LDRB a1, [a2,#1]!
TEQ a1, #&0
LDMEQFD sp!, {a2,pc}
BL DebugTX
B %BT1
DebugHexTX
stmfd r13!, {r0-r3,lr}
b jbdt1
DebugHexTX2
stmfd r13!, {r0-r3,lr}
b jbdt2
DebugHexTX4
stmfd r13!, {r0-r3,lr}
mov r0,r0,ror #24 ; hi byte
bl jbdtxh
mov r0,r0,ror #24
bl jbdtxh
jbdt2
mov r0,r0,ror #24
bl jbdtxh
mov r0,r0,ror #24
jbdt1
bl jbdtxh
mov r0,#' '
bl DebugTX
ldmfd r13!, {r0-r3,pc}
DebugTXStrInline
stmfd r13!, {r0-r3} ; lr points to prinstring, immediately
; following call, null terminated
sub r3,lr,#1
1 ldrb r0,[r3,#1]! ; pop next char, auto incr
teq r0,#0 ; terminating null
biceq lr,r3,#3 ; round down address
ldmeqfd r13!,{r0-r3}
addeq pc,lr,#4 ; return to next word
bl DebugTX ; else send, then
b %bt1 ; loop
jbdtxh stmfd r13!,{r0-r3,lr} ; print byte as hex
and a4,a1,#&f ; get low nibble
and a1,a1,#&f0 ; get hi nibble
mov a1,a1,lsr #4 ; shift to low nibble
cmp a1,#&9 ; 9?
addle a1,a1,#&30
addgt a1,a1,#&37 ; convert letter if needed
bl DebugTX
cmp a4,#9
addle a1,a4,#&30
addgt a1,a4,#&37
bl DebugTX
ldmfd r13!,{r0-r3,pc}
DebugTX
stmfd r13!,{r0,r8,r9,lr}
mov r8,#0
mov r9, #86 ; HAL_DebugTX
SWI XOS_Hardware
ldmfd r13!,{r0,r8,r9,pc}
]
END
; Copyright 2012 Castle Technology Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
GET GraphicsV
MACRO
GVEntry $name
ASSERT . - GraphicsV_Table = GraphicsV_$name * 4
B GV_$name
MEND
; Reason code is in R4 lower bytes. bits 31..24 = display number, default 0
GraphicsV_Handler
Push "lr"
; LDRB lr, instance ; may need another if more than 1 graphics module
; TEQ lr, R4, LSR #24 ; our display?
; Pull "pc", NE
BIC r4, r4, #&ff000000 ; clear display number
CMP r4, #(GraphicsV_TableEnd - GraphicsV_Table) / 4
ADDLO pc, pc, r4, LSL #2
Pull "pc"
GraphicsV_Table
Pull "pc" ;
Pull "pc" ; GV_VSync irq occurred
GVEntry SetMode ; GV_SetMode
Pull "pc"; GVEntry SetInterlace ; GV_SetInterlace
Pull "pc"; GVEntry SetBlank ; GV_SetBlank
GVEntry UpdatePointer ; GV_UpdatePointer
Pull "pc"; GVEntry SetDMAAddress ; GV_SetAddress
GVEntry VetMode ; GV_VetMode
GVEntry DisplayFeatures ; GV_Features
GVEntry FramestoreAddress ; GV_FramestoreAddress
GVEntry WritePaletteEntry ; GV_WritePaletteEntry
GVEntry WritePaletteEntries ; GV_WritePaletteEntries
Pull "pc" ;
GVEntry Render ; GV_Render
Pull "pc"; GVEntry IICOp ; GV_IICOp
Pull "pc"; GVEntry SelectHead ; GV_SelectHead
GraphicsV_TableEnd
GV_VetMode
Push "r2"
BL VetModeFromVIDCList
MOV r4, #0
Pull "r2,pc"
GV_SetMode
Push "r2"
BL SetModeFromVIDCList
MOV r4, #0
Pull "r2,pc"
GV_SetBlank
; BL SetBlankState
MOV r4, #0
Pull "pc"
GV_SelectHead
; BL SelectHead
MOV r4, #0
Pull "pc"
[ :LNOT: SWPointer
GV_UpdatePointer
MOV r4, #0
Pull "pc"
]
GV_SetDMAAddress
Pull "pc"
GV_DisplayFeatures
MOV r0, #2_111100 ; 100000 .. Framestore does Mem Alloc
; 010000 .. Doesn't generate VSync IRQ
; 001000 .. separate frame buffer
; 000100 .. interlace w progressive fb
; 000010 .. have hardware pointer
; 000001 .. hardware scroll
[ {FALSE}
MOV r1, #2_111000 ; 8,16,32bpp supported
|
MOV r1, #2_101000 ; 8,32bpp supported. 16bpp is RGB565, i.e. 2_RRRRRGGGGGGBBBBB
]
MOV r2, #4 ; framestore must be word aligned
MOV r4, #0
Pull "pc"
GV_FramestoreAddress
[ Debug
bl DebugTXStrInline
DCB "GC_FSA size, base", 0
ALIGN
]
LDR r1, mbscrsz
[ Debug
mov r0, r1
bl DebugHexTX4
]
LDR r0, mbbase
[ Debug
bl DebugHexTX4
]
MOV r4, #0
[ Debug
bl DebugTXStrInline
DCB 10,13, 0
ALIGN
]
Pull "pc"
GV_WritePaletteEntry ROUT
MOV r4, #0
CMP r0, #1
BGT %FT50
Pull "pc", EQ ; Border colour not supported
; Standard palette entry
LDR lr, mbbpp
CMP lr, #8
Pull "pc", NE
Push "r1,r3"
MOV r3, #1
MOV r1, sp
BL SetPalette
Pull "r1,r3,pc"
50
[ SWPointer
ADR lr, CurPalette
STR r1, [lr, r2, LSL #2]
]
Pull "pc"
GV_WritePaletteEntries ROUT
MOV r4, #0
CMP r3, #0
CMPNE r0, #1
BGT %FT50
Pull "pc", EQ ; Zero palette entries, or border colour
; Standard palette entries
LDR lr, mbbpp
CMP lr, #8
Pull "pc", NE
BL SetPalette
Pull "pc"
50
[ SWPointer
Push "r0,r3"
ADR lr, CurPalette
ADD lr, lr, r2, LSL #2
60
LDR r0, [r1], #4
STR r0, [lr], #4
SUBS r3, r3, #1
BNE %BT60
Pull "r0,r3"
]
Pull "pc"
; R0= 0(off)or 1(on)
GV_SetInterlace
; BL DoSetInterlace
; MOV r4, #0
Pull "pc"
GV_IICOp
; BL DoI2COp
; MOV r4, #0
Pull "pc"
GV_Render
[ SWPointer
; Remove pointer before any render op
Push "r0"
LDR r0, CurAddr
CMP r0, #1 ; cursor active?
CMPHI r1, #0 ; and not no-op call?
BLHI cur_remove
Pull "r0"
]
Pull "pc"
END
; Copyright 2012 Castle Technology Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
GV_UpdatePointer ROUT
MOV r4, #0
Push "r0"
; bail if pointer updates blocked
LDR r0, CurAddr
CMP r0, #1
BEQ %FT99
; remove cursor from previous position, if any
BLHI cur_remove
; Plot in new position, if any
LDR r0, [sp]
TST r0, #1
BLNE cur_plot
99
Pull "r0,pc"
cur_remove ROUT
; Remove cursor from addr r0
Entry "r0-r5"
LDR r1, CurHeight
CMP r1, #0
BEQ cur_remove_exit
ADR r2, CurUnder
LDR r3, mbpitch
LDR r4, mbbpp
CMP r4, #16
SUB r3, r3, r4, LSL #2
MOV r4, #0
STR r4, CurAddr
BLT cur_remove_8bpp
BEQ cur_remove_16bpp
; 32bpp
Push "r6-r11"
10
LDMIA r2!, {r4-r11} ; 8 pixels
STMIA r0!, {r4-r11}
LDMIA r2!, {r4-r11} ; 16 pixels
STMIA r0!, {r4-r11}
LDMIA r2!, {r4-r11} ; 24 pixels
STMIA r0!, {r4-r11}
LDMIA r2!, {r4-r11} ; 32 pixels
STMIA r0!, {r4-r11}
SUBS r1, r1, #1
ADD r0, r0, r3
BNE %BT10
Pull "r6-r11"
cur_remove_exit
STR r1, CurAddr
EXIT
cur_remove_8bpp ROUT
10
MOV r4, #32
20
LDRB r5, [r2], #1
SUBS r4, r4, #1
STRB r5, [r0], #1
BNE %BT20
SUBS r1, r1, #1
ADD r0, r0, r3
BNE %BT10
B cur_remove_exit
cur_remove_16bpp ROUT
10
MOV r4, #32
20
LDRH r5, [r2], #2
SUBS r4, r4, #1
STRH r5, [r0], #2
BNE %BT20
SUBS r1, r1, #1
ADD r0, r0, r3
BNE %BT10
B cur_remove_exit
cur_plot ROUT
; Plot cursor shape R3 at R1,R2
; Assume 32 pixel width
Entry "r0-r9"
MOV r0, #0
STR r0, CurAddr
; Work out log addr of screen
LDR r0, mbbase
LDR r4, VC_Base
SUB r0, r0, r4
LDR r4, VC_Log
ADD r0, r0, r4
LDRB r6, [r3, #1] ; Get height
CMP r6, #0
BEQ cur_plot_exit ; Nothing to plot!
CMP r6, #32
MOVGT r6, #32 ; paranoia
STR r6, CurHeight
LDR r8, mbxvres
LDR r9, mbyvres
CMP r1, r8
CMPLT r2, r9
BGE cur_plot_exit ; off bottom/right
; we don't do any clipping, so clamp position to lie on screen
SUB r8, r8, #32
SUB r9, r9, r6
CMP r1, r8
MOVGT r1, r8
CMP r2, r9
MOVGT r2, r9
ADDS r8, r1, #32
ADDGES r9, r2, r6
BLE cur_plot_exit ; off top/left
MOV r5, #1 ; Block updates just in case we abort
STR r5, CurAddr
CMP r1, #0
MOVLT r1, #0
CMP r2, #0
MOVLT r2, #0
LDR r5, mbbpp
LDR r4, mbpitch
MLA r0, r2, r4, r0
CMP r5, #16
ADR r7, CurPalette
ADR r8, CurUnder
LDR r3, [r3, #4]
SUB r4, r4, r5, LSL #2
BLT cur_plot_8bpp
BEQ cur_plot_16bpp
; 32bpp
ADD r0, r0, r1, LSL #2
Push "r0"
; r0 = screen address
; r3 = shape
; r4 = screen pitch, minus 32 pixels
; r6 = cursor height
; r7 = cursor palette
; r8 = CurUnder
10
LDR r1, =&88888888
LDRB r2, [r3], #1
20
LDR r5, [r0], #4
STR r5, [r8], #4
ANDS r9, r2, #3
LDRNE r9, [r7, r9, LSL #2]
MOVNE r9, r9, LSR #8
STRNE r9, [r0, #-4]
MOV r2, r2, LSR #2
MOVS r1, r1, LSR #1
LDRHIB r2, [r3], #1
BNE %BT20
ADD r0, r0, r4
SUBS r6, r6, #1
BNE %BT10
Pull "r0"
STR r0, CurAddr
cur_plot_exit
EXIT
cur_plot_8bpp ROUT
ADD r0, r0, r1
Push "r0"
10
LDR r1, =&88888888
LDRB r2, [r3], #1
20
LDRB r5, [r0], #1
STRB r5, [r8], #1
ANDS r9, r2, #3
EORNE r5, r5, #255 ; TODO - Something better!
STRNEB r5, [r0, #-1]
MOV r2, r2, LSR #2
MOVS r1, r1, LSR #1
LDRHIB r2, [r3], #1
BNE %BT20
ADD r0, r0, r4
SUBS r6, r6, #1
BNE %BT10
Pull "r0"
STR r0, CurAddr
EXIT
cur_plot_16bpp ROUT
ADD r0, r0, r1, LSL #1
Push "r0"
10
LDR r1, =&88888888
LDRB r2, [r3], #1
20
LDRH r5, [r0], #2
STRH r5, [r8], #2
ANDS r9, r2, #3
BEQ %FT30
LDR r9, [r7, r9, LSL #2]
AND r5, r9, #&f8000000
AND lr, r9, #&00f80000
AND r9, r9, #&0000f800
ORR r5, r5, lr, LSL #3
ORR r5, r5, r9, LSL #8+3-5
MOV r5, r5, LSR #17
STRH r5, [r0, #-2]
30
MOV r2, r2, LSR #2
MOVS r1, r1, LSR #1
LDRHIB r2, [r3], #1
BNE %BT20
ADD r0, r0, r4
SUBS r6, r6, #1
BNE %BT10
Pull "r0"
STR r0, CurAddr
EXIT
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