-
Notifications
You must be signed in to change notification settings - Fork 19
/
sc0710-dma-channels.c
124 lines (101 loc) · 3.25 KB
/
sc0710-dma-channels.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Driver for the Elgato 4k60 Pro mk.2 HDMI capture card.
*
* Copyright (c) 2021-2022 Steven Toth <stoth@kernellabs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include "sc0710.h"
int sc0710_dma_channels_resize(struct sc0710_dev *dev)
{
printk(KERN_ERR "%s()\n", __func__);
switch (dev->board) {
case SC0710_BOARD_ELGATEO_4KP60_MK2:
sc0710_dma_channel_resize(dev, 0, CHDIR_INPUT, 0x1000, CHTYPE_VIDEO);
sc0710_dma_channel_resize(dev, 1, CHDIR_INPUT, 0x1100, CHTYPE_AUDIO);
break;
}
return 0;
}
int sc0710_dma_channels_alloc(struct sc0710_dev *dev)
{
switch (dev->board) {
case SC0710_BOARD_ELGATEO_4KP60_MK2:
sc0710_dma_channel_alloc(dev, 0, CHDIR_INPUT, 0x1000, CHTYPE_VIDEO);
sc0710_dma_channel_alloc(dev, 1, CHDIR_INPUT, 0x1100, CHTYPE_AUDIO);
break;
}
return 0;
}
void sc0710_dma_channels_free(struct sc0710_dev *dev)
{
int i;
for (i = 0; i < SC0710_MAX_CHANNELS; i++) {
sc0710_dma_channel_free(dev, i);
}
}
void sc0710_dma_channels_stop(struct sc0710_dev *dev)
{
int i, ret;
printk("%s()\n", __func__);
sc_clr(dev, 0, BAR0_00D0, 0x0001);
for (i = 0; i < SC0710_MAX_CHANNELS; i++) {
ret = sc0710_dma_channel_stop(&dev->channel[i]);
}
}
int sc0710_dma_channels_start(struct sc0710_dev *dev)
{
int i, ret;
printk("%s()\n", __func__);
/* Prepare all DMA channels to start */
for (i = 0; i < SC0710_MAX_CHANNELS; i++) {
ret = sc0710_dma_channel_start_prep(&dev->channel[i]);
}
/* TODO: What do these registers do? Any documentation? */
/* Digging into the reference drivers for the SCxxxx cards available
* from the CM's website, the hardware supports a video scaler.
* I'm guessing that this is setting - maybe - a scaler? */
/* TODO: This register needs to be set to the height of the incoming
* signal format.
*/
sc_write(dev, 0, BAR0_00C8, 0x438); /* 1080 */
sc_write(dev, 0, BAR0_00D0, 0x4100);
sc_write(dev, 0, 0xcc, 0);
sc_write(dev, 0, 0xdc, 0);
sc_write(dev, 0, BAR0_00D0, 0x4300);
sc_write(dev, 0, BAR0_00D0, 0x4100);
/* Start all DMA channels. */
for (i = 0; i < SC0710_MAX_CHANNELS; i++) {
ret = sc0710_dma_channel_start(&dev->channel[i]);
}
sc_set(dev, 0, BAR0_00D0, 0x0001);
return 0;
}
/* Called every 2m in polled DMA mode, check
* each dma channel. If writeback metadata suggests a transfer
* has completed, process it and hand the audio/video to linux
* subsystems.
*/
int sc0710_dma_channels_service(struct sc0710_dev *dev)
{
int i, ret;
for (i = 0; i < SC0710_MAX_CHANNELS; i++) {
ret = sc0710_dma_channel_service(&dev->channel[i]);
}
return 0;
}