Skip to content

Commit e39845d

Browse files
committed
drm/i915/dsb: Introduce intel_dsb_reg_write_masked()
Add a function for emitting masked register writes. Note that the mask is implemented through byte enables, so can only mask off aligned 8bit sets of bits. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230606191504.18099-10-ville.syrjala@linux.intel.com Reviewed-by: Uma Shankar <uma.shankar@intel.com>
1 parent df3b919 commit e39845d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/gpu/drm/i915/display/intel_dsb.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,24 @@ void intel_dsb_reg_write(struct intel_dsb *dsb,
234234
}
235235
}
236236

237+
static u32 intel_dsb_mask_to_byte_en(u32 mask)
238+
{
239+
return (!!(mask & 0xff000000) << 3 |
240+
!!(mask & 0x00ff0000) << 2 |
241+
!!(mask & 0x0000ff00) << 1 |
242+
!!(mask & 0x000000ff) << 0);
243+
}
244+
245+
/* Note: mask implemented via byte enables! */
246+
void intel_dsb_reg_write_masked(struct intel_dsb *dsb,
247+
i915_reg_t reg, u32 mask, u32 val)
248+
{
249+
intel_dsb_emit(dsb, val,
250+
(DSB_OPCODE_MMIO_WRITE << DSB_OPCODE_SHIFT) |
251+
(intel_dsb_mask_to_byte_en(mask) << DSB_BYTE_EN_SHIFT) |
252+
i915_mmio_reg_offset(reg));
253+
}
254+
237255
void intel_dsb_noop(struct intel_dsb *dsb, int count)
238256
{
239257
int i;

drivers/gpu/drm/i915/display/intel_dsb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void intel_dsb_finish(struct intel_dsb *dsb);
1919
void intel_dsb_cleanup(struct intel_dsb *dsb);
2020
void intel_dsb_reg_write(struct intel_dsb *dsb,
2121
i915_reg_t reg, u32 val);
22+
void intel_dsb_reg_write_masked(struct intel_dsb *dsb,
23+
i915_reg_t reg, u32 mask, u32 val);
2224
void intel_dsb_noop(struct intel_dsb *dsb, int count);
2325
void intel_dsb_commit(struct intel_dsb *dsb,
2426
bool wait_for_vblank);

0 commit comments

Comments
 (0)