aboutsummaryrefslogtreecommitdiff
path: root/fesvr/rfb.h
blob: 263663a24d1e496f8e51aa5f0918bfbae32d554b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _RFB_H
#define _RFB_H

#include "device.h"
#include "memif.h"
#include <pthread.h>

// remote frame buffer
class rfb_t : public device_t
{
 public:
  rfb_t(int display = 0);
  ~rfb_t();
  void tick();
  std::string name() { return "RISC-V"; }
  const char* identity() { return "rfb"; }

 private:
  template <typename T>
  std::string str(T x)
  {
    return std::string((char*)&x, sizeof(x));
  }
  size_t fb_bytes() { return size_t(width) * height * bpp/8; }
  void thread_main();
  friend void* rfb_thread_main(void*);
  std::string pixel_format();
  void fb_update(const std::string& s);
  void set_encodings(const std::string& s);
  void set_pixel_format(const std::string& s);
  void write(const std::string& s);
  std::string read();
  void handle_configure(command_t cmd);
  void handle_set_address(command_t cmd);

  int sockfd;
  int afd;
  memif_t* memif;
  reg_t addr;
  uint16_t width;
  uint16_t height;
  uint16_t bpp;
  int display;
  pthread_t thread;
  volatile char* volatile fb1;
  volatile char* volatile fb2;
  size_t read_pos;
  pthread_mutex_t lock;

  static const int FB_ALIGN = 256;
};

#endif