Skip to content

Commit 84ce68d

Browse files
committed
display/drm: Code quality improvements
1 parent 3e52a75 commit 84ce68d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/video_display/drm.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,9 @@ static Drm_framebuffer create_dumb_fb(int dri, int width, int height, uint32_t p
707707
}
708708

709709
{
710-
uint32_t handles[] = {buf.handle.get().handle, 0, 0, 0};
711-
uint32_t pitches[] = {buf.pitch, 0, 0, 0};
712-
uint32_t offsets[] = {0, 0, 0, 0};
710+
const uint32_t handles[] = {buf.handle.get().handle, 0, 0, 0};
711+
const uint32_t pitches[] = {buf.pitch, 0, 0, 0};
712+
constexpr uint32_t offsets[] = {0, 0, 0, 0};
713713
Fb_id fb_id;
714714
res = drmModeAddFB2(dri, width, height,
715715
pix_fmt, handles, pitches, offsets, &fb_id.id, 0);
@@ -726,7 +726,7 @@ static Drm_framebuffer create_dumb_fb(int dri, int width, int height, uint32_t p
726726
log_msg(LOG_LEVEL_INFO, MOD_NAME "Created dumb buffer: pitch %u, handle: %u\n", buf.pitch, buf.handle.get().handle);
727727

728728

729-
struct drm_mode_map_dumb map_info = {};
729+
drm_mode_map_dumb map_info = {};
730730
map_info.handle = buf.handle.get().handle;
731731

732732
res = drmIoctl(dri, DRM_IOCTL_MODE_MAP_DUMB, &map_info);
@@ -735,7 +735,7 @@ static Drm_framebuffer create_dumb_fb(int dri, int width, int height, uint32_t p
735735
return {};
736736
}
737737

738-
buf.map = MemoryMapping::create(0, buf.size, PROT_READ | PROT_WRITE, MAP_SHARED, dri, map_info.offset);
738+
buf.map = MemoryMapping::create(nullptr, buf.size, PROT_READ | PROT_WRITE, MAP_SHARED, dri, map_info.offset);
739739
if(!buf.map.valid()){
740740
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Failed to map buffer\n");
741741
return {};
@@ -893,7 +893,7 @@ static void display_drm_done(void *state)
893893
}
894894
}
895895

896-
static struct video_frame *display_drm_getf(void *state)
896+
static video_frame *display_drm_getf(void *state)
897897
{
898898
auto s = static_cast<drm_display_state *>(state);
899899

@@ -919,7 +919,7 @@ static Drm_prime_fb drm_fb_from_frame(drm_display_state *s, frame_uniq frame){
919919

920920
Drm_prime_fb fb;
921921
fb.frame = std::move(frame);
922-
auto drm_frame = (drm_prime_frame *) fb.frame->tiles[0].data;
922+
const auto drm_frame = reinterpret_cast<drm_prime_frame *>(fb.frame->tiles[0].data);
923923

924924
for(int i = 0; i < drm_frame->fd_count; i++){
925925
fb.gem_objects[i] = s->drm.gem_manager->get_handle(drm_frame->dmabuf_fds[i]);
@@ -1038,7 +1038,7 @@ static bool display_drm_get_property(void *state, int property, void *val, size_
10381038
return true;
10391039
}
10401040

1041-
static bool display_drm_reconfigure(void *state, struct video_desc desc)
1041+
static bool display_drm_reconfigure(void *state, video_desc desc)
10421042
{
10431043
auto s = static_cast<drm_display_state *>(state);
10441044

@@ -1101,7 +1101,7 @@ static void display_drm_probe(struct device_info **available_cards, int *count,
11011101
*count = 0;
11021102
}
11031103

1104-
static const struct video_display_info display_drm_info = {
1104+
static constexpr video_display_info display_drm_info = {
11051105
display_drm_probe,
11061106
display_drm_init,
11071107
nullptr, // _run

0 commit comments

Comments
 (0)