drm/vc4: hvs: Provide a function to initialize the HVS structure
We'll need to initialize the HVS structure without a backing device to create a mock we'll use for testing. Split the structure initialization part into a separate function. Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-16-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard <maxime@cerno.tech>
This commit is contained in:
@@ -1009,6 +1009,7 @@ void vc4_irq_reset(struct drm_device *dev);
|
||||
|
||||
/* vc4_hvs.c */
|
||||
extern struct platform_driver vc4_hvs_driver;
|
||||
struct vc4_hvs *__vc4_hvs_alloc(struct vc4_dev *vc4, struct platform_device *pdev);
|
||||
void vc4_hvs_stop_channel(struct vc4_hvs *hvs, unsigned int output);
|
||||
int vc4_hvs_get_fifo_from_output(struct vc4_hvs *hvs, unsigned int output);
|
||||
u8 vc4_hvs_get_fifo_frame_count(struct vc4_hvs *hvs, unsigned int fifo);
|
||||
|
@@ -768,6 +768,46 @@ int vc4_hvs_debugfs_init(struct drm_minor *minor)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct vc4_hvs *__vc4_hvs_alloc(struct vc4_dev *vc4, struct platform_device *pdev)
|
||||
{
|
||||
struct drm_device *drm = &vc4->base;
|
||||
struct vc4_hvs *hvs;
|
||||
|
||||
hvs = drmm_kzalloc(drm, sizeof(*hvs), GFP_KERNEL);
|
||||
if (!hvs)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
hvs->vc4 = vc4;
|
||||
hvs->pdev = pdev;
|
||||
|
||||
spin_lock_init(&hvs->mm_lock);
|
||||
|
||||
/* Set up the HVS display list memory manager. We never
|
||||
* overwrite the setup from the bootloader (just 128b out of
|
||||
* our 16K), since we don't want to scramble the screen when
|
||||
* transitioning from the firmware's boot setup to runtime.
|
||||
*/
|
||||
drm_mm_init(&hvs->dlist_mm,
|
||||
HVS_BOOTLOADER_DLIST_END,
|
||||
(SCALER_DLIST_SIZE >> 2) - HVS_BOOTLOADER_DLIST_END);
|
||||
|
||||
/* Set up the HVS LBM memory manager. We could have some more
|
||||
* complicated data structure that allowed reuse of LBM areas
|
||||
* between planes when they don't overlap on the screen, but
|
||||
* for now we just allocate globally.
|
||||
*/
|
||||
if (!vc4->is_vc5)
|
||||
/* 48k words of 2x12-bit pixels */
|
||||
drm_mm_init(&hvs->lbm_mm, 0, 48 * 1024);
|
||||
else
|
||||
/* 60k words of 4x12-bit pixels */
|
||||
drm_mm_init(&hvs->lbm_mm, 0, 60 * 1024);
|
||||
|
||||
vc4->hvs = hvs;
|
||||
|
||||
return hvs;
|
||||
}
|
||||
|
||||
static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
@@ -778,11 +818,9 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
|
||||
u32 dispctrl;
|
||||
u32 reg;
|
||||
|
||||
hvs = drmm_kzalloc(drm, sizeof(*hvs), GFP_KERNEL);
|
||||
if (!hvs)
|
||||
return -ENOMEM;
|
||||
hvs->vc4 = vc4;
|
||||
hvs->pdev = pdev;
|
||||
hvs = __vc4_hvs_alloc(vc4, NULL);
|
||||
if (IS_ERR(hvs))
|
||||
return PTR_ERR(hvs);
|
||||
|
||||
hvs->regs = vc4_ioremap_regs(pdev, 0);
|
||||
if (IS_ERR(hvs->regs))
|
||||
@@ -835,29 +873,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
|
||||
else
|
||||
hvs->dlist = hvs->regs + SCALER5_DLIST_START;
|
||||
|
||||
spin_lock_init(&hvs->mm_lock);
|
||||
|
||||
/* Set up the HVS display list memory manager. We never
|
||||
* overwrite the setup from the bootloader (just 128b out of
|
||||
* our 16K), since we don't want to scramble the screen when
|
||||
* transitioning from the firmware's boot setup to runtime.
|
||||
*/
|
||||
drm_mm_init(&hvs->dlist_mm,
|
||||
HVS_BOOTLOADER_DLIST_END,
|
||||
(SCALER_DLIST_SIZE >> 2) - HVS_BOOTLOADER_DLIST_END);
|
||||
|
||||
/* Set up the HVS LBM memory manager. We could have some more
|
||||
* complicated data structure that allowed reuse of LBM areas
|
||||
* between planes when they don't overlap on the screen, but
|
||||
* for now we just allocate globally.
|
||||
*/
|
||||
if (!vc4->is_vc5)
|
||||
/* 48k words of 2x12-bit pixels */
|
||||
drm_mm_init(&hvs->lbm_mm, 0, 48 * 1024);
|
||||
else
|
||||
/* 60k words of 4x12-bit pixels */
|
||||
drm_mm_init(&hvs->lbm_mm, 0, 60 * 1024);
|
||||
|
||||
/* Upload filter kernels. We only have the one for now, so we
|
||||
* keep it around for the lifetime of the driver.
|
||||
*/
|
||||
@@ -867,8 +882,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
vc4->hvs = hvs;
|
||||
|
||||
reg = HVS_READ(SCALER_DISPECTRL);
|
||||
reg &= ~SCALER_DISPECTRL_DSP2_MUX_MASK;
|
||||
HVS_WRITE(SCALER_DISPECTRL,
|
||||
|
Reference in New Issue
Block a user