This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OMAP3525: Omap

Part Number: OMAP3525

How to capture screen using drm api? how to get the frame buffer and pass it to GStreamer api.

I`m using IOCTl

int main()
{
//------------------------------------------------------------------------------
//Opening the DRI device
//------------------------------------------------------------------------------

int dri_fd = open("/dev/dri/card0",O_RDWR | O_CLOEXEC);

//------------------------------------------------------------------------------
//Kernel Mode Setting (KMS)
//------------------------------------------------------------------------------

uint64_t res_fb_buf[10]={0},
res_crtc_buf[10]={0},
res_conn_buf[10]={0},
res_enc_buf[10]={0};

struct drm_mode_card_res res={0};

//Become the "master" of the DRI device
ioctl(dri_fd, DRM_IOCTL_SET_MASTER, 0);

//Get resource counts
ioctl(dri_fd, DRM_IOCTL_MODE_GETRESOURCES, &res);


res.fb_id_ptr=(uint64_t)res_fb_buf;

res.crtc_id_ptr=(uint64_t)res_crtc_buf;

res.connector_id_ptr=(uint64_t)res_conn_buf;

res.encoder_id_ptr=(uint64_t)res_enc_buf;

//Get resource IDs
ioctl(dri_fd, DRM_IOCTL_MODE_GETRESOURCES, &res);

printf("fb: %d, crtc: %d, conn: %d, enc: %d\n",res.count_fbs,res.count_crtcs,res.count_connectors,res.count_encoders);

void *fb_base[10];
long fb_w[10];
long fb_h[10];

//Loop though all available connectors
int i;
for (i=0;i<res.count_connectors;i++)
{
struct drm_mode_modeinfo conn_mode_buf[20]={0};
uint64_t conn_prop_buf[20]={0},
conn_propval_buf[20]={0},
conn_enc_buf[20]={0};

struct drm_mode_get_connector conn={0};

conn.connector_id=res_conn_buf[i];

ioctl(dri_fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn); //get connector resource counts

conn.modes_ptr=(uint64_t)conn_mode_buf;

conn.props_ptr=(uint64_t)conn_prop_buf;

conn.prop_values_ptr=(uint64_t)conn_propval_buf;

conn.encoders_ptr=(uint64_t)conn_enc_buf;

ioctl(dri_fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn); //get connector resources

//Check if the connector is OK to use (connected to something)
if (conn.count_encoders<1 || conn.count_modes<1 || !conn.encoder_id || !conn.connection)
{
printf("Not connected\n");
continue;
}

//Kernel Mode Setting (KMS)

//------------------------------------------------------------------------------

printf("%d : mode: %d, prop: %d, enc: %d\n",conn.connection,conn.count_modes,conn.count_props,conn.count_encoders);
printf("modes: %dx%d FB: %d\n",conn_mode_buf[0].hdisplay,conn_mode_buf[0].vdisplay,fb_base[i]);

struct drm_mode_get_encoder enc={0};

enc.encoder_id=conn.encoder_id;

ioctl(dri_fd, DRM_IOCTL_MODE_GETENCODER, &enc); //get encoder

struct drm_mode_crtc crtc={0};

crtc.crtc_id=enc.crtc_id;

ioctl(dri_fd, DRM_IOCTL_MODE_GETCRTC, &crtc);

printf("Next : %s : %d\n",crtc.mode.name, crtc.fb_id);


}
fflush(stdout);

//Stop being the "master" of the DRI device
ioctl(dri_fd, DRM_IOCTL_DROP_MASTER, 0);