Home | History | Annotate | Download | only in linux_perf
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 'use strict';
      6 
      7 /**
      8  * @fileoverview Parses drm driver events in the Linux event trace format.
      9  */
     10 base.require('tracing.importer.linux_perf.parser');
     11 base.exportTo('tracing.importer.linux_perf', function() {
     12 
     13   var Parser = tracing.importer.linux_perf.Parser;
     14 
     15   /**
     16    * Parses linux drm trace events.
     17    * @constructor
     18    */
     19   function DrmParser(importer) {
     20     Parser.call(this, importer);
     21 
     22     importer.registerEventHandler('drm_vblank_event',
     23         DrmParser.prototype.vblankEvent.bind(this));
     24   }
     25 
     26   DrmParser.prototype = {
     27     __proto__: Parser.prototype,
     28 
     29     drmVblankSlice: function(ts, eventName, args) {
     30       var kthread = this.importer.getOrCreatePseudoThread('drm_vblank');
     31       kthread.openSlice = eventName;
     32       var slice = new tracing.trace_model.Slice('', kthread.openSlice,
     33           tracing.getStringColorId(kthread.openSlice), ts, args, 0);
     34 
     35       kthread.thread.sliceGroup.pushSlice(slice);
     36     },
     37 
     38     /**
     39      * Parses drm driver events and sets up state in the importer.
     40      */
     41     vblankEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
     42       var event = /crtc=(\d+), seq=(\d+)/.exec(eventBase.details);
     43       if (!event)
     44         return false;
     45 
     46       var crtc = parseInt(event[1]);
     47       var seq = parseInt(event[2]);
     48       this.drmVblankSlice(ts, 'vblank:' + crtc,
     49           {
     50             crtc: crtc,
     51             seq: seq
     52           });
     53       return true;
     54     }
     55   };
     56 
     57   Parser.registerSubtype(DrmParser);
     58 
     59   return {
     60     DrmParser: DrmParser
     61   };
     62 });
     63