-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add I2S Bus driver (required for reading ACPI properties)
- Loading branch information
Showing
18 changed files
with
1,596 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2023 CoolStar | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Rockchip Bus Driver for Rockchip 3xxx I2S | ||
|
||
* Exposes I2S resources | ||
* Support accessing topology |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include "driver.h" | ||
#define ADSP_DECL 1 | ||
#include "adsp.h" | ||
|
||
NTSTATUS ADSPGetResources(_In_ PVOID _context, _Out_ _PCI_BAR* acpBar, PTPLG_INFO tplgInfo) { | ||
if (!_context) | ||
return STATUS_NO_SUCH_DEVICE; | ||
|
||
PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context; | ||
if (!devData->FdoContext) { | ||
return STATUS_NO_SUCH_DEVICE; | ||
} | ||
|
||
if (acpBar) { | ||
*acpBar = devData->FdoContext->m_MMIO; | ||
} | ||
|
||
if (tplgInfo) { | ||
if (devData->FdoContext->rkTplg) { | ||
tplgInfo->rkTplg = devData->FdoContext->rkTplg; | ||
tplgInfo->rkTplgSz = devData->FdoContext->rkTplgSz; | ||
} | ||
} | ||
|
||
return STATUS_SUCCESS; | ||
} | ||
|
||
NTSTATUS ADSPSetPowerState(_In_ PVOID _context, _In_ DEVICE_POWER_STATE powerState) { | ||
if (!_context) | ||
return STATUS_NO_SUCH_DEVICE; | ||
|
||
PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context; | ||
if (!devData->FdoContext) { | ||
return STATUS_NO_SUCH_DEVICE; | ||
} | ||
|
||
NTSTATUS status = STATUS_SUCCESS; | ||
if (powerState == PowerDeviceD3) { | ||
WdfDeviceResumeIdle(devData->FdoContext->WdfDevice); | ||
} else if (powerState == PowerDeviceD0) { | ||
status = WdfDeviceStopIdle(devData->FdoContext->WdfDevice, TRUE); | ||
} | ||
return status; | ||
} | ||
|
||
NTSTATUS ADSPRegisterInterrupt(_In_ PVOID _context, _In_ PADSP_INTERRUPT_CALLBACK callback, _In_ PADSP_DPC_CALLBACK dpcCallback, _In_ PVOID callbackContext) { | ||
if (!_context) | ||
return STATUS_NO_SUCH_DEVICE; | ||
|
||
PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context; | ||
if (!devData->FdoContext) { | ||
return STATUS_NO_SUCH_DEVICE; | ||
} | ||
|
||
devData->FdoContext->dspInterruptCallback = callback; | ||
devData->FdoContext->dspDPCCallback = dpcCallback; | ||
devData->FdoContext->dspInterruptContext = callbackContext; | ||
|
||
return STATUS_SUCCESS; | ||
} | ||
|
||
NTSTATUS ADSPUnregisterInterrupt(_In_ PVOID _context) { | ||
if (!_context) | ||
return STATUS_NO_SUCH_DEVICE; | ||
|
||
PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context; | ||
if (!devData->FdoContext) { | ||
return STATUS_NO_SUCH_DEVICE; | ||
} | ||
|
||
devData->FdoContext->dspInterruptCallback = NULL; | ||
devData->FdoContext->dspInterruptContext = NULL; | ||
return STATUS_SUCCESS; | ||
} | ||
|
||
NTSTATUS ADSPQueueDpcForInterrupt(_In_ PVOID _context) { | ||
if (!_context) | ||
return STATUS_NO_SUCH_DEVICE; | ||
|
||
PPDO_DEVICE_DATA devData = (PPDO_DEVICE_DATA)_context; | ||
if (!devData->FdoContext) { | ||
return STATUS_NO_SUCH_DEVICE; | ||
} | ||
|
||
BOOL ret = WdfInterruptQueueDpcForIsr(devData->FdoContext->Interrupt); | ||
return ret ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; | ||
} | ||
|
||
RKDSP_BUS_INTERFACE RKDSP_BusInterface(PVOID Context) { | ||
RKDSP_BUS_INTERFACE busInterface; | ||
RtlZeroMemory(&busInterface, sizeof(RKDSP_BUS_INTERFACE)); | ||
|
||
busInterface.Size = sizeof(RKDSP_BUS_INTERFACE); | ||
busInterface.Version = 1; | ||
busInterface.Context = Context; | ||
busInterface.InterfaceReference = WdfDeviceInterfaceReferenceNoOp; | ||
busInterface.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp; | ||
busInterface.GetResources = ADSPGetResources; | ||
busInterface.SetDSPPowerState = ADSPSetPowerState; | ||
busInterface.RegisterInterrupt = ADSPRegisterInterrupt; | ||
busInterface.UnregisterInterrupt = ADSPUnregisterInterrupt; | ||
busInterface.QueueDPCForInterrupt = ADSPQueueDpcForInterrupt; | ||
|
||
return busInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef __ADSP_INTERFACE | ||
#define __ADSP_INTERFACE | ||
// | ||
// The GUID_RKDSP_BUS_INTERFACE interface GUID | ||
// | ||
// {863DD2AC-5B54-4C57-8487-782F9ADFE8D7} | ||
DEFINE_GUID(GUID_RKDSP_BUS_INTERFACE, | ||
0x863dd2ac, 0x5b54, 0x4c57, 0x84, 0x87, 0x78, 0x2f, 0x9a, 0xdf, 0xe8, 0xd7); | ||
|
||
typedef struct _TPLG_INFO { | ||
PVOID rkTplg; | ||
UINT64 rkTplgSz; | ||
} TPLG_INFO, * PTPLG_INFO; | ||
|
||
typedef _Must_inspect_result_ NTSTATUS(*PGET_ADSP_RESOURCES) (_In_ PVOID _context, _Out_ _PCI_BAR* acpBar, PTPLG_INFO tplgInfo); | ||
typedef _Must_inspect_result_ NTSTATUS(*PDSP_SET_POWER_STATE) (_In_ PVOID _context, _In_ DEVICE_POWER_STATE newPowerState); | ||
typedef _Must_inspect_result_ BOOL(*PADSP_INTERRUPT_CALLBACK)(PVOID context); | ||
typedef _Must_inspect_result_ VOID(*PADSP_DPC_CALLBACK)(PVOID context); | ||
typedef _Must_inspect_result_ NTSTATUS (*PADSP_QUEUE_DPC)(PVOID context); | ||
typedef _Must_inspect_result_ NTSTATUS(*PREGISTER_ADSP_INTERRUPT) (_In_ PVOID _context, _In_ PADSP_INTERRUPT_CALLBACK callback, _In_ PADSP_DPC_CALLBACK dpcCallback, _In_ PVOID callbackContext); | ||
typedef _Must_inspect_result_ NTSTATUS(*PUNREGISTER_ADSP_INTERRUPT) (_In_ PVOID _context); | ||
|
||
typedef struct _RKDSP_BUS_INTERFACE | ||
{ | ||
// | ||
// First we define the standard INTERFACE structure ... | ||
// | ||
USHORT Size; | ||
USHORT Version; | ||
PVOID Context; | ||
PINTERFACE_REFERENCE InterfaceReference; | ||
PINTERFACE_DEREFERENCE InterfaceDereference; | ||
|
||
// | ||
// Then we expand the structure with the ADSP_BUS_INTERFACE stuff. | ||
|
||
PGET_ADSP_RESOURCES GetResources; | ||
PDSP_SET_POWER_STATE SetDSPPowerState; | ||
PREGISTER_ADSP_INTERRUPT RegisterInterrupt; | ||
PUNREGISTER_ADSP_INTERRUPT UnregisterInterrupt; | ||
PADSP_QUEUE_DPC QueueDPCForInterrupt; | ||
} RKDSP_BUS_INTERFACE, * PRKDSP_BUS_INTERFACE; | ||
|
||
#ifndef ADSP_DECL | ||
RKDSP_BUS_INTERFACE RKDSP_BusInterface(PVOID Context); | ||
#endif | ||
#endif |
Oops, something went wrong.