Skip to content

Commit

Permalink
Re-formatted code by indent
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Sep 22, 2022
1 parent 9f3107b commit 637ba56
Showing 1 changed file with 43 additions and 28 deletions.
71 changes: 43 additions & 28 deletions rpi_framebuffer/rpi_fb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ typedef struct fb_fix_screeninfo ModeInfo;
* pixelu ve framebufferu. Zobrazene informace maji vyznam pouze ve chvili,
* kdy se nepouzivaji graficke rezimy s barvovovu paletou.
*/
void printColorInfo(const char *message, const struct fb_bitfield colorInfo)
void printColorInfo(const char *message,
const struct fb_bitfield colorInfo)
{
puts(message);
printf(" sirka: %d\n", colorInfo.length);
Expand All @@ -51,7 +52,7 @@ void printColorInfo(const char *message, const struct fb_bitfield colorInfo)
*/
const char *getFramebufferType(const int type)
{
static const char *FRAMEBUFFER_TYPES[]={
static const char *FRAMEBUFFER_TYPES[] = {
"Packed Pixels",
"Non interleaved planes",
"Interleaved planes",
Expand All @@ -72,7 +73,7 @@ const char *getFramebufferType(const int type)
*/
const char *getVideoMode(const int mode)
{
static const char *VIDEO_MODE_TYPES[]={
static const char *VIDEO_MODE_TYPES[] = {
"non interlaced",
"interlaced",
"non interlaced, double scan",
Expand All @@ -89,7 +90,7 @@ const char *getVideoMode(const int mode)
*/
const char *getGraphicsMode(const int mode)
{
static const char *GRAPHIC_MODES[]={
static const char *GRAPHIC_MODES[] = {
"Monochr. 1=Black 0=White",
"Monochr. 1=White 0=Black",
"True color",
Expand All @@ -112,8 +113,8 @@ const char *getGraphicsMode(const int mode)
* (postacuje byt ve skupine 'video' ci pouziti su/sudo)
*/
int readFramebufferInfo(int framebufferDevice,
FramebufferInfo *framebufferInfoPtr,
ModeInfo *modeInfoPtr)
FramebufferInfo * framebufferInfoPtr,
ModeInfo * modeInfoPtr)
{
/* Pokud operace ioctl probehne v poradku, vrati se 0 */
if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, framebufferInfoPtr)) {
Expand All @@ -134,30 +135,43 @@ int readFramebufferInfo(int framebufferDevice,
* Vypis vsech relevantnich informaci zjistenych o framebufferu.
*/
void printFramebufferInfo(int framebufferDevice,
FramebufferInfo *framebufferInfoPtr,
ModeInfo *modeInfoPtr)
FramebufferInfo * framebufferInfoPtr,
ModeInfo * modeInfoPtr)
{
/* Nyni je datova struktura FramebufferInfo naplnena. */
printf("Realne rozliseni: %dx%d pixelu\n", framebufferInfoPtr->xres, framebufferInfoPtr->yres);
printf("Virtualni rozliseni: %dx%d pixelu\n", framebufferInfoPtr->xres_virtual, framebufferInfoPtr->yres_virtual);
printf("Odstiny sedi: %s\n", framebufferInfoPtr->grayscale ? "ano" : "ne");
printf("Nestandardni format: %s\n", framebufferInfoPtr->nonstd ? "ano" : "ne");
printf("Rezim zobrazovani: %d == %s\n", framebufferInfoPtr->vmode, getVideoMode(framebufferInfoPtr->vmode));

printf("Bitu na pixel: %d bitu\n", framebufferInfoPtr->bits_per_pixel);
printColorInfo("Cervena barvova slozka (RED):", framebufferInfoPtr->red);
printColorInfo("Zelena barvova slozka (GREEN):", framebufferInfoPtr->green);
printColorInfo("Modra barvova slozka (BLUE):", framebufferInfoPtr->blue);
printColorInfo("Alfa kanal (ALPHA):", framebufferInfoPtr->transp);
printf("Realne rozliseni: %dx%d pixelu\n",
framebufferInfoPtr->xres, framebufferInfoPtr->yres);
printf("Virtualni rozliseni: %dx%d pixelu\n",
framebufferInfoPtr->xres_virtual,
framebufferInfoPtr->yres_virtual);
printf("Odstiny sedi: %s\n",
framebufferInfoPtr->grayscale ? "ano" : "ne");
printf("Nestandardni format: %s\n",
framebufferInfoPtr->nonstd ? "ano" : "ne");
printf("Rezim zobrazovani: %d == %s\n", framebufferInfoPtr->vmode,
getVideoMode(framebufferInfoPtr->vmode));

printf("Bitu na pixel: %d bitu\n",
framebufferInfoPtr->bits_per_pixel);
printColorInfo("Cervena barvova slozka (RED):",
framebufferInfoPtr->red);
printColorInfo("Zelena barvova slozka (GREEN):",
framebufferInfoPtr->green);
printColorInfo("Modra barvova slozka (BLUE):",
framebufferInfoPtr->blue);
printColorInfo("Alfa kanal (ALPHA):", framebufferInfoPtr->transp);

putchar('\n');

/* Nyni je datova struktura modeInfo naplnena. */
printf("Identifikace: %s\n", modeInfoPtr->id);
printf("Delka obrazoveho radku: %d bajtu\n", modeInfoPtr->line_length);
printf("Delka obrazoveho radku: %d bajtu\n",
modeInfoPtr->line_length);
printf("Velikost framebufferu: %d bajtu\n", modeInfoPtr->smem_len);
printf("Organizace framebufferu: %d == %s\n", modeInfoPtr->type, getFramebufferType(modeInfoPtr->type));
printf("Graficky rezim: %d == %s\n", modeInfoPtr->visual, getGraphicsMode(modeInfoPtr->visual));
printf("Organizace framebufferu: %d == %s\n", modeInfoPtr->type,
getFramebufferType(modeInfoPtr->type));
printf("Graficky rezim: %d == %s\n", modeInfoPtr->visual,
getGraphicsMode(modeInfoPtr->visual));
}


Expand All @@ -166,23 +180,25 @@ void printFramebufferInfo(int framebufferDevice,
int main(int argc, char **argv)
{
FramebufferInfo framebufferInfo;
ModeInfo modeInfo;
ModeInfo modeInfo;
int framebufferDevice = 0;

/* Ze zarizeni potrebujeme pouze cist.*/
/* Ze zarizeni potrebujeme pouze cist. */
framebufferDevice = open("/dev/fb0", O_RDONLY);

/* Pokud otevreni probehlo uspesne, nacteme
* a nasledne vypiseme informaci o framebufferu.*/
if (framebufferDevice != -1) {
/* Precteni informaci o framebufferu a test, zda se vse podarilo */
if (readFramebufferInfo(framebufferDevice, &framebufferInfo, &modeInfo)) {
printFramebufferInfo(framebufferDevice, &framebufferInfo, &modeInfo);
if (readFramebufferInfo
(framebufferDevice, &framebufferInfo, &modeInfo)) {
printFramebufferInfo(framebufferDevice, &framebufferInfo,
&modeInfo);
}
close(framebufferDevice);
return 0;
}
/* Otevreni se nezadarilo, vypiseme tudiz pouze chybove hlaseni.*/
/* Otevreni se nezadarilo, vypiseme tudiz pouze chybove hlaseni. */
else {
perror("Nelze otevrit ovladac /dev/fb0");
return 1;
Expand All @@ -192,4 +208,3 @@ int main(int argc, char **argv)


/* finito */

0 comments on commit 637ba56

Please sign in to comment.