This patch fixes a number of issues with the ptouch-driver printer driver:

  * Update the driver to use current CUPS APIs (not the older deprecated ones)
    and fix some compile-time warnings
  * Use the PPD API to get the value of the MediaType flag, which is used to
    pass the "Roll-fed media" flag into the driver
  * Correct the margins for QL-series P-Touch paper-label printers - these
    have a fixed 3mm margin (see the command spec) while the PT-series
    laminated plastic label printers have no appreciable margins.
  * Correct the format of the "ESC i z" (Print Information) command to match
    what is specified in the P-touch 500 raster command spec. Notably set the
    "passed parameter valid" bits, and send valid values for die-cut labels
    and continuous paper rolls.
  * Send the "ESC i d" (Set Margin) command for QL series printers. This is
    required by the command spec. The margin is set to 3mm for continuous
    paper and zero for die-cut (see the command spec)
  * Fix an issue with margins in the driver (disable blank-line padding). This
    was partly responsible for the "excess paper feed" issue.
  * Suppress the spurious "ESC i z" which was sent with incorrect contents at
    the start of the job.
  * Fix the Enable Cutter command.
  * Send 350 bytes of NULL/no-op commands at the start of the job. This allows
    the driver to recover the printer into a known state if communication was
    interrupted mid-transfer. This is recommended in the command spec.
  * Remove the "determined by page size" option from "Roll-fed media" as this
    no longer works.
  * Remove the "Advance Media" option, as this allowed users to configure the
    driver to generate print control codes which are illegal per the Brother
    documentation. This is now fixed at "Advance at end of job" (send a Form
    Feed at the end of every page, except the last which has an Eject
    command instead).
  * Merge in the changes formerly provided by send-esc-i-A-for-QL-only.patch.

See also:
  Brother QL Series Command Reference (QL-500/550/560/570/580N/650TD/700/1050/1060N)
  <http://download.brother.com/welcome/docp000678/cv_qlseries_eng_raster_600.pdf>

Author: Philip Pemberton <philpem@philpem.me.uk>
--- a/rastertoptch.c
+++ b/rastertoptch.c
@@ -297,8 +297,6 @@
 #define IMAGE_HEIGHT_DEFAULT       0
 /** Feed amount default */
 #define FEED_DEFAULT               0
-/** When to perform feed default */
-#define PERFORM_FEED_DEFAULT       CUPS_ADVANCE_NONE
 
 #include <config.h>
 #include <stdio.h>
@@ -432,6 +430,7 @@
   int label_preamble;   /**< emit ESC i z ...                     */
   bool concat_pages;    /**< remove interlabel margins            */
   unsigned long rle_alloc_max; /**< max bytes used for rle_buffer */
+  bool roll_fed_media;     /**< continuous (not labels) roll media */
 } job_options_t;
 
 /**
@@ -440,12 +439,10 @@
 typedef struct {
   cups_cut_t cut_media;    /**< cut media mode                     */
   cups_bool_t mirror;      /**< mirror printing                    */
-  bool roll_fed_media;     /**< continuous (not labels) roll media */
   unsigned resolution [2]; /**< horiz & vertical resolution in DPI */
   unsigned page_size [2];  /**< width & height of page in points   */
   unsigned image_height;   /**< height of page image in pixels     */
   unsigned feed;           /**< feed size in points                */
-  cups_adv_t perform_feed; /**< When to feed                       */
 } page_options_t;
 
 /**
@@ -469,12 +466,40 @@
     LABEL_PREAMBLE_DEFAULT,
     CONCAT_PAGES_DEFAULT,
     RLE_ALLOC_MAX_DEFAULT,
+    ROLL_FED_MEDIA_DEFAULT,
   };
   if (argc < 6) return options;
   int num_options = 0;
   cups_option_t* cups_options = NULL;
+  ppd_file_t		*ppd;		/* PPD file */
   num_options
     = cupsParseOptions (argv [5], num_options, &cups_options);
+
+  // Load job options from the PPD file
+  ppd = ppdOpenFile(getenv("PPD"));
+  if (!ppd) {
+    ppd_status_t	status;		/* PPD error */
+    int			linenum;	/* Line number */
+
+    fprintf(stderr, "ERROR: The PPD file could not be opened.");
+
+    status = ppdLastError(&linenum);
+
+    fprintf(stderr, "DEBUG: %s on line %d.\n", ppdErrorString(status), linenum);
+
+    exit(EXIT_FAILURE);
+  }
+  ppdMarkDefaults(ppd);
+  cupsMarkOptions(ppd, num_options, cups_options);
+
+  // Use PPD API to decode RollFedMedia choice
+    ppd_choice_t *choice = ppdFindMarkedChoice(ppd, "RollFedMedia");
+    fprintf(stderr, "DEBUG: Markedchoice for roll fed media is '%s', text '%s'\n", choice->choice, choice->text);
+    options.roll_fed_media /* Default is continuous roll */
+      = (strcasecmp ("Labels", choice->choice) != 0);
+
+
+  // FIXME use PPD API
   const char* cups_option
     = cupsGetOption ("PixelXfer", num_options, cups_options);
   if (cups_option) {
@@ -526,8 +551,12 @@
   OBTAIN_INT_OPTION ("TransferMode", xfer_mode, 0, 255);
   OBTAIN_BOOL_OPTION ("SoftwareMirror", software_mirror);
   OBTAIN_BOOL_OPTION ("LabelPreamble", label_preamble);
-  /* Release memory allocated for CUPS options struct */
+
+  /* Close the PPD file and
+   * Release memory allocated for CUPS options struct */
+  ppdClose(ppd);
   cupsFreeOptions (num_options, cups_options);
+
   return options;
 }
 
@@ -559,20 +588,25 @@
  * @param page_options  page options to be updated
  */
 void
-update_page_options (cups_page_header_t* header,
+update_page_options (cups_page_header2_t* header,
                      page_options_t* page_options) {
   page_options->cut_media = header->CutMedia;
   page_options->mirror = header->MirrorPrint;
   const char* media_type = header->MediaType;
-  page_options->roll_fed_media /* Default is continuous roll */
-    = (strcasecmp ("Labels", media_type) != 0);
   page_options->resolution [0] = header->HWResolution [0];
   page_options->resolution [1] = header->HWResolution [1];
   page_options->page_size [0] = header->PageSize [0];
   page_options->page_size [1] = header->PageSize [1];
   page_options->image_height = header->cupsHeight;
   page_options->feed = header->AdvanceDistance;
-  page_options->perform_feed = header->AdvanceMedia;
+
+  fprintf(stderr, "DEBUG: ==== PAGE OPTIONS ====\n");
+  fprintf(stderr, "DEBUG: Cut Media = %d\n", header->CutMedia);
+  fprintf(stderr, "DEBUG: Media Type = [%s]\n", header->MediaType);
+  fprintf(stderr, "DEBUG: Resolution = [%d %d]\n", header->HWResolution[0], header->HWResolution[1]);
+  fprintf(stderr, "DEBUG: PageSize = [%d %d]\n", header->PageSize[0], header->PageSize[1]);
+  fprintf(stderr, "DEBUG: ImageHeight (header->cupsHeight) = %d\n", header->cupsHeight);
+  fprintf(stderr, "DEBUG: Advance Distance = %d\n", header->AdvanceDistance);
 }
 
 void cancel_job (int signal);
@@ -654,6 +688,13 @@
  */
 void
 emit_job_cmds (job_options_t* job_options) {
+  /* Send 350 bytes of NULL to clear print buffer in case an error occurred
+   * previously. The printer ignores 0x00 bytes if it's waiting for a command.
+   */
+  int i;
+  for (i=0; i<350; i++) {
+    putchar(0x00);
+  }
   /* Initialise printer */
   putchar (ESC); putchar ('@');
   /* Emit print density selection command if required */
@@ -685,7 +726,8 @@
 inline void
 emit_feed_cut_mirror (bool do_feed, unsigned feed,
                       bool do_cut,
-                      bool do_mirror) {
+                      bool do_mirror,
+                      xfer_t xfer_mode) {
   /* Determine feed nibble */
   unsigned feed_nibble;
   if (do_feed) {
@@ -698,6 +740,14 @@
   /* Determine mirror print bit*/
   unsigned char mirror_bit = do_mirror ? 0x80 : 0x00;
   /* Combine & emit printer command code */
+  if (xfer_mode == ULP) {
+    /* ESC i A is Enable Cutter -- used for QL-560 only, according to
+     * <http://www.undocprint.org/formats/page_description_languages/brother_p-touch>
+     * The QL-560 (actually the whole QL series) uses ULP mode, so we check for that.
+     * The PT2450DX uses RLE and throw an INTERFACE ERROR if it sees this command.
+     */
+    putchar (ESC); putchar ('i'); putchar ('A'); putchar ((char) (do_cut ? 0x01 : 0x00));
+  }
   putchar (ESC); putchar ('i'); putchar ('M');
   putchar ((char) (feed & 0x1f) | auto_cut_bit | mirror_bit);
 }
@@ -714,11 +764,19 @@
                            page_options_t* page_options,
                            unsigned page_size_y,
                            unsigned image_height_px) {
-  bool roll_fed_media = page_options->roll_fed_media;
+
+  static bool first_page = true;  // True if this is the first page
+                                  // (this function is only called once per page)
+
+  const unsigned char PI_KIND = 0x02;   // Paper type (roll fed media bit) is valid
+  const unsigned char PI_WIDTH = 0x04;  // Paper width is valid
+  const unsigned char PI_LENGTH = 0x08; // Paper length is valid
+
+  bool roll_fed_media = job_options->roll_fed_media;
   /* Determine print quality bit */
   unsigned char print_quality_bit
     = (job_options->print_quality_high == CUPS_TRUE) ? 0x40 : 0x00;
-  unsigned char roll_fed_media_bit = roll_fed_media ? 0x00 : 0x01;
+  unsigned char paper_type_id = roll_fed_media ? 0x0A : 0x0B;
   /* Get tape width in mm */
   int tape_width_mm = lrint (page_options->page_size [0] * MM_PER_PT);
   if (tape_width_mm > 0xff) {
@@ -741,11 +799,28 @@
   }
   /* Combine & emit printer command code */
   putchar (ESC); putchar ('i'); putchar ('z');
-  putchar (print_quality_bit); putchar (roll_fed_media_bit);
-  putchar (tape_width_mm & 0xff); putchar (tape_height_mm & 0xff);
+  putchar (print_quality_bit | PI_KIND | PI_WIDTH | PI_LENGTH);
+  putchar (paper_type_id);
+  putchar (tape_width_mm & 0xff);
+  putchar (tape_height_mm & 0xff);
   putchar (image_height_px & 0xff);
   putchar ((image_height_px >> 8) & 0xff);
-  putchar (0x00); putchar (0x00); putchar (0x00); putchar (0x00);
+  putchar ((image_height_px >> 16) & 0xff);
+  putchar ((image_height_px >> 24) & 0xff);
+  putchar (first_page ? 0x00 : 0x01);   // n9: 0 for first page, 1 for other pages
+  putchar (0x00);   // n10, always 0
+
+  first_page = false;
+
+  /* Send a SET MARGIN command */
+  putchar(ESC); putchar('i'); putchar('d');
+  if (roll_fed_media) {
+    /* Continuous tape, specify 35 dots (3mm) */
+    putchar(35); putchar(0);
+  } else {
+    /* Die-cut labels, specify no margin */
+    putchar(0); putchar(0);
+  }
 }
 /**
  * Emit printer command codes at start of page for options that have
@@ -795,31 +870,20 @@
 
   /* Set feed, auto cut and mirror print */
   unsigned feed = new_page_options->feed;
-  cups_adv_t perform_feed = new_page_options->perform_feed;
   cups_cut_t cut_media = new_page_options->cut_media;
   cups_bool_t mirror = new_page_options->mirror;
   if (force
       || feed != old_page_options->feed
-      || perform_feed != old_page_options->perform_feed
       || cut_media != old_page_options->cut_media
       || mirror != old_page_options->mirror)
     /* We only know how to feed after each page */
-    emit_feed_cut_mirror (perform_feed == CUPS_ADVANCE_PAGE, feed,
+    emit_feed_cut_mirror (false, feed,
                           cut_media == CUPS_CUT_PAGE,
-                          mirror == CUPS_TRUE);
-  /* Set media and quality if label preamble is requested */
+                          mirror == CUPS_TRUE,
+                          job_options->pixel_xfer);
+
   unsigned page_size_y = new_page_options->page_size [1];
   unsigned image_height_px = lrint (page_size_y * vres / 72.0);
-  if (job_options->label_preamble && !job_options->concat_pages
-      && (force
-          || (new_page_options->roll_fed_media
-              != old_page_options->roll_fed_media)
-          || new_page_size_x != old_page_size_x
-          || page_size_y != old_page_options->page_size [1]))
-    emit_quality_rollfed_size (job_options, new_page_options,
-                               page_size_y, image_height_px);
-
-  /* WHY DON'T WE SET MARGIN (ESC i d ...)? */
 
   /* Set pixel data transfer compression */
   if (force) {
@@ -907,7 +971,7 @@
 #ifdef DEBUG
   if (debug)
     fprintf (stderr, "DEBUG: generate_emit_line "
-             "(in_buffer=%0x, out_buffer=%0x, "
+             "(in_buffer=%p, out_buffer=%p, "
              "buflen=%d, bytes_per_line=%d, right_padding_bytes=%d, "
              "shift=%d, do_mirror=%d, xormask=%0x)\n",
              in_buffer, out_buffer, buflen, bytes_per_line,
@@ -1068,7 +1132,7 @@
 #ifdef DEBUG
   if (debug)
     fprintf (stderr, "DEBUG: ensure_rle_buf_space (bytes=%d): "
-             "increasing rle_buffer from %d to %d\n",
+             "increasing rle_buffer from %zu to %zu\n",
              bytes,
              rle_alloced * sizeof (char),
              new_alloced * sizeof (char));
@@ -1291,7 +1355,7 @@
                    job_options_t* job_options,
                    page_options_t* page_options,
                    cups_raster_t* ras,
-                   cups_page_header_t* header) {
+                   cups_page_header2_t* header) {
   unsigned char xormask = (header->NegativePrint ? ~0 : 0);
   /* Determine whether we need to mirror the pixel data */
   int do_mirror = job_options->software_mirror && page_options->mirror;
@@ -1362,8 +1426,10 @@
     unsigned top_distance_pt
       = page_size_y - header->ImagingBoundingBox [3];
     if (top_distance_pt != 0) {
+      fprintf(stderr, "DEBUG: philpem -- Top distance pt nonzero, %d\n", top_distance_pt);
       top_empty_lines = lrint (top_distance_pt * scale_pt2ypixels);
-      empty_lines += top_empty_lines;
+      fprintf(stderr, "DEBUG: philpem -- Top empty lines %d\n", top_empty_lines);
+      //empty_lines += top_empty_lines;
     }
   }
   /* Generate and store actual page data */
@@ -1404,6 +1470,11 @@
     bot_empty_lines = image_height_px - top_empty_lines - y;
   else
     bot_empty_lines = 0;
+
+
+  fprintf(stderr, "DEBUG: philpem -- Bottom empty lines %d\n", bot_empty_lines);
+  bot_empty_lines = 0;
+
   if (bot_empty_lines != 0 && !job_options->concat_pages)
     empty_lines += bot_empty_lines;
   fprintf (stderr,
@@ -1423,19 +1494,17 @@
 process_rasterdata (int fd, job_options_t* job_options) {
   int page = 1;                    /* Page number                   */
   cups_raster_t* ras;              /* Raster stream for printing    */
-  cups_page_header_t header;       /* Current page header           */
+  cups_page_header2_t header;       /* Current page header           */
   int first_page = true;           /* Is this the first page?       */
   int more_pages;                  /* Are there more pages left?    */
   int bytes_per_line = job_options->bytes_per_line;
   page_options_t page_options [2] = {{
     CUT_MEDIA_DEFAULT,
     MIRROR_DEFAULT,
-    ROLL_FED_MEDIA_DEFAULT,
     RESOLUTION_DEFAULT,
     PAGE_SIZE_DEFAULT,
     IMAGE_HEIGHT_DEFAULT,
-    FEED_DEFAULT,
-    PERFORM_FEED_DEFAULT,}
+    FEED_DEFAULT,}
   };                               /* Current & preceding page opts */
   page_options_t* new_page_options
     = page_options + 0;            /* Options for current page      */
@@ -1443,7 +1512,7 @@
     = page_options + 1;            /* Options for preceding page    */
   page_options_t* tmp_page_options;/* Temp variable for swapping    */
   ras = cupsRasterOpen (fd, CUPS_RASTER_READ);
-  for (more_pages = cupsRasterReadHeader (ras, &header);
+  for (more_pages = cupsRasterReadHeader2 (ras, &header);
        more_pages;
        tmp_page_options = old_page_options,
          old_page_options = new_page_options,
@@ -1452,6 +1521,7 @@
     update_page_options (&header, new_page_options);
 #ifdef DEBUG
     if (debug) {
+      fprintf (stderr, "DEBUG: MediaType = %s\n", header.MediaType);
       fprintf (stderr, "DEBUG: pixel_xfer = %d\n", job_options->pixel_xfer);
       fprintf (stderr, "DEBUG: print_quality_high = %d\n", job_options->print_quality_high);
       fprintf (stderr, "DEBUG: half_cut = %d\n", job_options->half_cut);
@@ -1464,12 +1534,11 @@
       fprintf (stderr, "DEBUG: concat_pages = %d\n", job_options->concat_pages);
       fprintf (stderr, "DEBUG: cut_media = %d\n", new_page_options->cut_media);
       fprintf (stderr, "DEBUG: mirror = %d\n", new_page_options->mirror);
-      fprintf (stderr, "DEBUG: roll_fed_media = %d\n", new_page_options->roll_fed_media);
+      fprintf (stderr, "DEBUG: roll_fed_media = %d\n", job_options->roll_fed_media);
       fprintf (stderr, "DEBUG: resolution = %d x %d\n", new_page_options->resolution [0], new_page_options->resolution [1]);
       fprintf (stderr, "DEBUG: page_size = %d x %d\n", new_page_options->page_size [0], new_page_options->page_size [1]);
       fprintf (stderr, "DEBUG: image_height = %d\n", new_page_options->image_height);
       fprintf (stderr, "DEBUG: feed = %d\n", new_page_options->feed);
-      fprintf (stderr, "DEBUG: perform_feed = %d\n", new_page_options->perform_feed);
       fprintf (stderr, "DEBUG: header->ImagingBoundingBox = [%u, %u, %u, %u]\n",
                header.ImagingBoundingBox [0], header.ImagingBoundingBox [1],
                header.ImagingBoundingBox [2], header.ImagingBoundingBox [3]);
@@ -1486,19 +1555,15 @@
     emit_raster_lines (page, job_options, new_page_options, ras, &header);
     unsigned char xormask = (header.NegativePrint ? ~0 : 0);
     /* Determine whether this is the last page (fetch next)    */
-    more_pages = cupsRasterReadHeader (ras, &header);
+    more_pages = cupsRasterReadHeader2 (ras, &header);
     /* Do feeding or ejecting at the end of each page. */
-    cups_adv_t perform_feed = new_page_options->perform_feed;
     if (more_pages) {
       if (!job_options->concat_pages) {
         RLE_store_empty_lines
           (job_options, page_options, empty_lines, xormask);
         empty_lines = 0;
         flush_rle_buffer (job_options, page_options);
-        if (perform_feed == CUPS_ADVANCE_PAGE)
-          putchar (PTC_EJECT);    /* Emit eject marker to force feed   */
-        else
-          putchar (PTC_FORMFEED); /* Emit page end marker without feed */
+        putchar (PTC_FORMFEED); /* Emit page end marker without feed */
       }
     } else {
       if (!job_options->concat_pages) {
@@ -1506,7 +1571,6 @@
           (job_options, page_options, empty_lines, xormask);
         empty_lines = 0;
         flush_rle_buffer (job_options, page_options);
-        putchar (PTC_FORMFEED);
       } else {
         double scale_pt2ypixels = header.HWResolution [1] / 72.0;
         unsigned bot_empty_lines
@@ -1518,18 +1582,8 @@
         flush_rle_buffer (job_options, page_options);
       }
 
-      /* If special feed or cut at job end, emit commands to that effect */
-      cups_cut_t cut_media = new_page_options->cut_media;
-      if (perform_feed == CUPS_ADVANCE_JOB || cut_media == CUPS_CUT_JOB) {
-        emit_feed_cut_mirror
-          (perform_feed == CUPS_ADVANCE_PAGE ||
-           perform_feed == CUPS_ADVANCE_JOB,
-           new_page_options->feed,
-           cut_media == CUPS_CUT_PAGE || cut_media == CUPS_CUT_JOB,
-           new_page_options->mirror == CUPS_TRUE);
-        /* Emit eject marker */
-        putchar (PTC_EJECT);
-      }
+      /* End of last page, send Eject command */
+      putchar (PTC_EJECT);
     }
     page_end ();
     /* Emit page count according to CUPS requirements */
--- a/printer/Brother-QL-500.xml
+++ b/printer/Brother-QL-500.xml
@@ -31,6 +31,15 @@
         <y>300</y>
       </dpi>
     </resolution>
+    <margins>
+      <general>
+        <unit>mm</unit>
+        <top>3</top>
+        <bottom>3</bottom>
+        <left>1.5</left>
+        <right>1.5</right>
+      </general>
+    </margins>
     <consumables>
       <comments>
         <en>
--- a/printer/Brother-QL-550.xml
+++ b/printer/Brother-QL-550.xml
@@ -31,6 +31,15 @@
         <y>300</y>
       </dpi>
     </resolution>
+    <margins>
+      <general>
+        <unit>mm</unit>
+        <top>3</top>
+        <bottom>3</bottom>
+        <left>1.5</left>
+        <right>1.5</right>
+      </general>
+    </margins>
     <consumables>
       <comments>
         <en>
--- a/printer/Brother-QL-650TD.xml
+++ b/printer/Brother-QL-650TD.xml
@@ -31,6 +31,15 @@
         <y>300</y>
       </dpi>
     </resolution>
+    <margins>
+      <general>
+        <unit>mm</unit>
+        <top>3</top>
+        <bottom>3</bottom>
+        <left>1.5</left>
+        <right>1.5</right>
+      </general>
+    </margins>
     <consumables>
       <comments>
         <en>
--- a/opt/Brother-Ptouch-RollFedMedia.xml
+++ b/opt/Brother-Ptouch-RollFedMedia.xml
@@ -41,19 +41,6 @@
     </constraint>
   </constraints>
   <enum_vals>
-   <enum_val id="ev/Auto">
-    <ev_longname>
-     <en>Automatically determined by page size</en>
-    </ev_longname>
-    <!-- A multilingual <comments> block can appear here, too;
-         it should be treated as documentation for the user. -->
-    <ev_shortname>
-     <en>Auto</en>
-     <!-- Until someone tells me how to learn the user locale in 
-          backends, the shortname must be monolingual in <en>! -->
-    </ev_shortname>
-    <ev_driverval></ev_driverval>
-   </enum_val>
    <enum_val id="ev/Roll">
     <ev_longname>
      <en>Continuous roll</en>
--- a/opt/Brother-Ptouch-AdvanceMedia.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<!--
-Copyright (c) 2006  Arne John Glenstrup <panic@itu.dk>
-
-This file is part of ptouch-driver.
-
-ptouch-driver is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or (at
-your option) any later version.
-
-ptouch-driver is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with ptouch-driver; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-USA
--->
-<option type='enum' id='Brother-Ptouch-AdvanceMedia'>
-  <!-- A multilingual <comments> block can appear here, too;
-       it should be treated as documentation for the user. -->
-  <arg_longname>
-    <en>Advance Media</en>
-  </arg_longname>
-  <arg_shortname>
-    <en>AdvanceMedia</en><!-- backends only know <en> shortnames! -->
-  </arg_shortname>
-  <arg_execution>
-    <arg_group>Finishing</arg_group>
-    <arg_order>110</arg_order>
-    <arg_spot>A</arg_spot>
-    <arg_postscript />
-    <arg_proto>&lt;&lt;/AdvanceMedia %s&gt;&gt;setpagedevice</arg_proto>
-  </arg_execution>
-  <constraints>
-    <constraint sense='true'>
-      <driver>ptouch</driver>
-      <arg_defval>ev/Off</arg_defval>
-    </constraint>
-  </constraints>
-  <enum_vals>
-   <enum_val id="ev/Off">
-    <ev_longname>
-     <en>Do not advance the tape</en>
-    </ev_longname>
-    <!-- A multilingual <comments> block can appear here, too;
-         it should be treated as documentation for the user. -->
-    <ev_shortname>
-     <en>Off</en>
-     <!-- Until someone tells me how to learn the user locale in
-          backends, the shortname must be monolingual in <en>! -->
-    </ev_shortname>
-    <ev_driverval>0</ev_driverval>
-   </enum_val>
-   <enum_val id="ev/LabelEnd">
-    <ev_longname>
-     <en>Advance the tape after each label</en>
-    </ev_longname>
-    <!-- A multilingual <comments> block can appear here, too;
-         it should be treated as documentation for the user. -->
-    <ev_shortname>
-     <en>LabelEnd</en>
-     <!-- Until someone tells me how to learn the user locale in
-          backends, the shortname must be monolingual in <en>! -->
-    </ev_shortname>
-    <ev_driverval>4</ev_driverval>
-   </enum_val>
-   <enum_val id="ev/JobEnd">
-    <ev_longname>
-     <en>Advance the tape at the end of the job</en>
-    </ev_longname>
-    <!-- A multilingual <comments> block can appear here, too;
-         it should be treated as documentation for the user. -->
-    <ev_shortname>
-     <en>JobEnd</en>
-     <!-- Until someone tells me how to learn the user locale in
-          backends, the shortname must be monolingual in <en>! -->
-    </ev_shortname>
-    <ev_driverval>2</ev_driverval>
-   </enum_val>
-  </enum_vals>
-</option>
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,6 @@
 				  printer/Brother-PT-9500PC.xml \
 				  printer/Brother-PT-9600.xml \
 				  opt/Brother-Ptouch-AdvanceDistance.xml \
-				  opt/Brother-Ptouch-AdvanceMedia.xml \
 				  opt/Brother-Ptouch-Align.xml \
 				  opt/Brother-Ptouch-BytesPerLine.xml \
 				  opt/Brother-Ptouch-ConcatPages.xml \
--- a/ptouch-driver-foomatic.spec.in
+++ b/ptouch-driver-foomatic.spec.in
@@ -76,7 +76,6 @@
 /usr/share/foomatic/db/source/printer/Brother-QL-550.xml
 /usr/share/foomatic/db/source/printer/Brother-QL-650TD.xml
 /usr/share/foomatic/db/source/opt/Brother-Ptouch-AdvanceDistance.xml
-/usr/share/foomatic/db/source/opt/Brother-Ptouch-AdvanceMedia.xml
 /usr/share/foomatic/db/source/opt/Brother-Ptouch-Align.xml
 /usr/share/foomatic/db/source/opt/Brother-Ptouch-BytesPerLine.xml
 /usr/share/foomatic/db/source/opt/Brother-Ptouch-ConcatPages.xml
