Skip to content

Commit e0f9b44

Browse files
mripardpelwell
authored andcommitted
drm/vc4: hvs: Use pointer to HVS in HVS_READ and HVS_WRITE macros
Those macros are really about the HVS itself, and thus its associated structure vc4_hvs, rather than the entire (virtual) vc4 device. Let's change those macros to use the hvs pointer directly, and change the calling sites accordingly. Signed-off-by: Maxime Ripard <[email protected]>
1 parent 42b22c1 commit e0f9b44

File tree

4 files changed

+77
-67
lines changed

4 files changed

+77
-67
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static const struct debugfs_reg32 crtc_regs[] = {
7070
static unsigned int
7171
vc4_crtc_get_cob_allocation(struct vc4_dev *vc4, unsigned int channel)
7272
{
73+
struct vc4_hvs *hvs = vc4->hvs;
7374
u32 dispbase = HVS_READ(SCALER_DISPBASEX(channel));
7475
/* Top/base are supposed to be 4-pixel aligned, but the
7576
* Raspberry Pi firmware fills the low bits (which are
@@ -89,6 +90,7 @@ static bool vc4_crtc_get_scanout_position(struct drm_crtc *crtc,
8990
{
9091
struct drm_device *dev = crtc->dev;
9192
struct vc4_dev *vc4 = to_vc4_dev(dev);
93+
struct vc4_hvs *hvs = vc4->hvs;
9294
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
9395
struct vc4_crtc_state *vc4_crtc_state = to_vc4_crtc_state(crtc->state);
9496
unsigned int cob_size;
@@ -123,7 +125,7 @@ static bool vc4_crtc_get_scanout_position(struct drm_crtc *crtc,
123125
*vpos /= 2;
124126

125127
/* Use hpos to correct for field offset in interlaced mode. */
126-
if (vc4_hvs_get_fifo_frame_count(dev, vc4_crtc_state->assigned_channel) % 2)
128+
if (vc4_hvs_get_fifo_frame_count(hvs, vc4_crtc_state->assigned_channel) % 2)
127129
*hpos += mode->crtc_htotal / 2;
128130
}
129131

@@ -449,6 +451,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
449451
static void require_hvs_enabled(struct drm_device *dev)
450452
{
451453
struct vc4_dev *vc4 = to_vc4_dev(dev);
454+
struct vc4_hvs *hvs = vc4->hvs;
452455

453456
WARN_ON_ONCE((HVS_READ(SCALER_DISPCTRL) & SCALER_DISPCTRL_ENABLE) !=
454457
SCALER_DISPCTRL_ENABLE);
@@ -462,6 +465,7 @@ static int vc4_crtc_disable(struct drm_crtc *crtc,
462465
struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
463466
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
464467
struct drm_device *dev = crtc->dev;
468+
struct vc4_dev *vc4 = to_vc4_dev(dev);
465469
int ret;
466470

467471
CRTC_WRITE(PV_V_CONTROL,
@@ -491,7 +495,7 @@ static int vc4_crtc_disable(struct drm_crtc *crtc,
491495
vc4_encoder->post_crtc_disable(encoder, state);
492496

493497
vc4_crtc_pixelvalve_reset(crtc);
494-
vc4_hvs_stop_channel(dev, channel);
498+
vc4_hvs_stop_channel(vc4->hvs, channel);
495499

496500
if (vc4_encoder && vc4_encoder->post_crtc_powerdown)
497501
vc4_encoder->post_crtc_powerdown(encoder, state);
@@ -517,6 +521,7 @@ static struct drm_encoder *vc4_crtc_get_encoder_by_type(struct drm_crtc *crtc,
517521
int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
518522
{
519523
struct drm_device *drm = crtc->dev;
524+
struct vc4_dev *vc4 = to_vc4_dev(drm);
520525
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
521526
enum vc4_encoder_type encoder_type;
522527
const struct vc4_pv_data *pv_data;
@@ -538,7 +543,7 @@ int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
538543
if (!(CRTC_READ(PV_V_CONTROL) & PV_VCONTROL_VIDEN))
539544
return 0;
540545

541-
channel = vc4_hvs_get_fifo_from_output(drm, vc4_crtc->data->hvs_output);
546+
channel = vc4_hvs_get_fifo_from_output(vc4->hvs, vc4_crtc->data->hvs_output);
542547
if (channel < 0)
543548
return 0;
544549

@@ -752,6 +757,7 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)
752757
struct drm_crtc *crtc = &vc4_crtc->base;
753758
struct drm_device *dev = crtc->dev;
754759
struct vc4_dev *vc4 = to_vc4_dev(dev);
760+
struct vc4_hvs *hvs = vc4->hvs;
755761
u32 chan = vc4_crtc->current_hvs_channel;
756762
unsigned long flags;
757763

@@ -770,7 +776,7 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)
770776
* the CRTC and encoder already reconfigured, leading to
771777
* underruns. This can be seen when reconfiguring the CRTC.
772778
*/
773-
vc4_hvs_unmask_underrun(dev, chan);
779+
vc4_hvs_unmask_underrun(hvs, chan);
774780
}
775781
spin_unlock(&vc4_crtc->irq_lock);
776782
spin_unlock_irqrestore(&dev->event_lock, flags);

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ to_vc4_crtc_state(struct drm_crtc_state *crtc_state)
603603

604604
#define V3D_READ(offset) readl(vc4->v3d->regs + offset)
605605
#define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset)
606-
#define HVS_READ(offset) readl(vc4->hvs->regs + offset)
607-
#define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
606+
#define HVS_READ(offset) readl(hvs->regs + offset)
607+
#define HVS_WRITE(offset, val) writel(val, hvs->regs + offset)
608608

609609
#define VC4_REG32(reg) { .name = #reg, .offset = reg }
610610

@@ -965,17 +965,17 @@ void vc4_irq_reset(struct drm_device *dev);
965965

966966
/* vc4_hvs.c */
967967
extern struct platform_driver vc4_hvs_driver;
968-
void vc4_hvs_stop_channel(struct drm_device *dev, unsigned int output);
969-
int vc4_hvs_get_fifo_from_output(struct drm_device *dev, unsigned int output);
970-
u8 vc4_hvs_get_fifo_frame_count(struct drm_device *dev, unsigned int fifo);
968+
void vc4_hvs_stop_channel(struct vc4_hvs *hvs, unsigned int output);
969+
int vc4_hvs_get_fifo_from_output(struct vc4_hvs *hvs, unsigned int output);
970+
u8 vc4_hvs_get_fifo_frame_count(struct vc4_hvs *hvs, unsigned int fifo);
971971
int vc4_hvs_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state);
972972
void vc4_hvs_atomic_begin(struct drm_crtc *crtc, struct drm_atomic_state *state);
973973
void vc4_hvs_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_state *state);
974974
void vc4_hvs_atomic_disable(struct drm_crtc *crtc, struct drm_atomic_state *state);
975975
void vc4_hvs_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state);
976-
void vc4_hvs_dump_state(struct drm_device *dev);
977-
void vc4_hvs_unmask_underrun(struct drm_device *dev, int channel);
978-
void vc4_hvs_mask_underrun(struct drm_device *dev, int channel);
976+
void vc4_hvs_dump_state(struct vc4_hvs *hvs);
977+
void vc4_hvs_unmask_underrun(struct vc4_hvs *hvs, int channel);
978+
void vc4_hvs_mask_underrun(struct vc4_hvs *hvs, int channel);
979979

980980
/* vc4_kms.c */
981981
int vc4_kms_load(struct drm_device *dev);

0 commit comments

Comments
 (0)